Reply to Re: [PHP] Problem with WHILE using MYSQL database

Your name:

Reply:


Posted by Curt Zirzow on 01/09/05 17:24

* Thus wrote Labunski:
>
> $data = mysql_query("SELECT * FROM firt_table WHERE cat='sweaters' ORDER BY
> `id` ASC ") or die("can't find DB!");
> while($line = mysql_fetch_array($data)){
> echo' <tr><td width="225" height="19"'.$line['product'].'</td></tr>';
> }
>
> for example, there are 3 records in the "first_table", so script will output
> only 3 records:
> <tr><td width="225" height="19"'.$line['product'].'</td></tr>
> <tr><td width="225" height="19"'.$line['product'].'</td></tr>
> <tr><td width="225" height="19"'.$line['product'].'</td></tr>
>
> It's ok. But I need to output 10 records always, even if there are less than
> 10 records in the database.

Just keep a counter for your while loop then output however meany
are left:

$i = 0;
while ($line = ...) {
$i++;
}

echo str_repeat('<tr><td>&nbsp;</td></tr>', 10 - $i);

or something to that effect.

Curt
--
Quoth the Raven, "Nevermore."

[Back to original 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

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