hi!
am trying to get my results from a query and format the results into 2 table columns(5 per column). somehow i figured out a way to do it but can somebody pls tell me if the code shown below can be made better?
*****************************************
<?php
// get results and rows
$results = mysql_query("select * from table order by rank", $db_connect);
$numrows = mysql_num_rows($results);
$limit = 5;
$col = intval($numrows/$limit);
?>
<table border="1" width="100%"><tr><td>
<?
// first column
for ($i=1;$i<=$col;$i++)
{
list($id, $img, $comment, $date, $link, $rank) = mysql_fetch_row($results);
echo "$id, <img src=http://www.phpbuilder.com/board/archive/index.php/\"$img\">, $comment, $date, $link, $rank<br>";
}
?>
</td><td>
<?php
// second column
for ($i=i+1;$i<=$col;$i++)
{
list($id, $img, $comment, $date, $link, $rank) = mysql_fetch_row($results);
echo "<td>$id, <img src=\"$img\">, $comment, $date, $link, $rank<br>";
}
?>
</td></tr></table>
*****************************************
and wat if i want the results separated to multiple pages?
thanks so much
am trying to get my results from a query and format the results into 2 table columns(5 per column). somehow i figured out a way to do it but can somebody pls tell me if the code shown below can be made better?
*****************************************
<?php
// get results and rows
$results = mysql_query("select * from table order by rank", $db_connect);
$numrows = mysql_num_rows($results);
$limit = 5;
$col = intval($numrows/$limit);
?>
<table border="1" width="100%"><tr><td>
<?
// first column
for ($i=1;$i<=$col;$i++)
{
list($id, $img, $comment, $date, $link, $rank) = mysql_fetch_row($results);
echo "$id, <img src=http://www.phpbuilder.com/board/archive/index.php/\"$img\">, $comment, $date, $link, $rank<br>";
}
?>
</td><td>
<?php
// second column
for ($i=i+1;$i<=$col;$i++)
{
list($id, $img, $comment, $date, $link, $rank) = mysql_fetch_row($results);
echo "<td>$id, <img src=\"$img\">, $comment, $date, $link, $rank<br>";
}
?>
</td></tr></table>
*****************************************
and wat if i want the results separated to multiple pages?
thanks so much