You are here: Re: [PHP] Walking through a bunch of MySQL Records « PHP « IT news, forums, messages
Re: [PHP] Walking through a bunch of MySQL Records

Posted by "Richard Lynch" on 11/14/05 22:03

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

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация