Hello
I have a database of some institutes, with their name and addresses. I want to list the NAMES column wise in HTML table. The HTML table will have 3 columns.
So if the mysql query gives 300 records, it will show the records like every column will have some data, so the column 1 will have records from 1 to 100, column 2 will have records from 101 to 200, and column 3 will have records from 201-300.
here is the current code, but its not working properly:
you can see the results herePHP Code:$qry = $con->select_query("institutes","distinct Names","order by Names");
$num_rows = mysql_num_rows($qry);
$per_col = ceil($num_rows/3);
echo $per_col;
$cnt = 1;
$no = 1;
$data = "<tr><td>";
while($row = mysql_fetch_object($qry))
{
if($cnt < $per_col+1)
{
$data .= "$no) $row->Names<br />";
}
else if($cnt == $per_col+1)
{
$data .= "</td>";
$data .= "<td>";
$data .= "$no) $row->Names<br />";
$cnt = 0;
}
$cnt++;
$no++;
}
$data .= "</tr>";
http://www.usabanklocations.com/index.php
Its seems OK, but just look at the top and bottom of column 1 and 2 they are not aligned.




Bookmarks