Jump to content

PHP loop out code help


kisazeky

Recommended Posts

I have a loop code that grabs data from the database and lists it on a webpage.

 

$article_title = "Shop";
$article_content = "Shop description goes here.<table<tr>";

$query = "SELECT * FROM adoptables WHERE kind = 'shop'";
$result = mysql_query($query);
$num = mysql_numrows($result);

//Loop out code
$i=0;
while ($i < $num) {

$aID=@mysql_result($result,$i,"uid");
$name=@mysql_result($result,$i,"name");
$imageurl=@mysql_result($result,$i,"imageurl");
$cost=@mysql_result($result,$i,"description");

//Content output
$article_content=$article_content."<td>".$name."<p><img src='".$imageurl."'/><p>".$cost." <p><a href='buy.php?aID=".$aID."'>Buy ".$name."</a></td>";

$i++;
}

$article_content=$article_content."</tr><tr>";

 

I want to arrange the data in table columns, with 5 items per row.

 

How can I accomplish this? ;D

Link to comment
https://forums.phpfreaks.com/topic/154509-php-loop-out-code-help/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.