Re: Walking through a bunch of MySQL Records

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, November 14, 2005 1:03 pm, Phillip S. Baker wrote:
> Greetings all,
>
> I have a question.
> I want to display a group of records pulled form a MySQL db in the
> following
> fashion.
>
> 1        6
> 2        7
> 3        8
> 4        9
> 5        10
>
> Now I can easily figure out how to display the records as
>
> 1        2
> 3        4
> 5        6
> 7        8
> 9        10
>
> But since I am in an HTML table and the need to display the <TR> and
> </TR> I
> am not sure how to make th logic so that I can get the first listing.
> Can
> anyone help me out?? Need more information??

$col = 0;
$row = 0;
$count = mysq_numrows($result);
$half_count = floor($count/2); //use ceiling to get "widow" on right
while (list($number) = mysql_fetch_row($result)){
  $table[$row][$col] = $number;
  $row++;
  if ($row == $half_count) $col++;
}
echo "<table>\n";
foreach($table as $row){
  echo "\t<tr>\n";
  foreach($row as $number){
    echo "\t\t<td>$number</td>\n";
  }
}
echo "</table>\n";

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux