View Single Post
  #7  
Old 02-10-2010, 12:09 AM
Arianna's Avatar
Arianna Arianna is offline
Dev Staff
 
Join Date: Sep 2009
Posts: 334
Gender: Female
Credits: 21,697
Arianna will become famous soon enough
Default RE: php question

This might not help you totally, because it's for my own script (not for this adoptables script), and it's for a shop, but it has a table which is made, making a new line every four columns.
PHP Code:
        $page .= "This is the item shop. Here you can buy a multitude of items for your pet to play with or use.<br />";
        
$query "SELECT * FROM ".$prefix."itemkinds WHERE kind='shop'";
        
$result mysql_query($query);
        
$num mysql_numrows($result);
        
$i=0;
        
$page .="<table style='border:0px;'><tr>";
        while (
$i<$num) {
            
// `id` , `name` , `desc` , `cost` , `kind` , `img`
            
$id=@mysql_result($result,$i,"id");
            
$name=@mysql_result($result,$i,"name");
            
$desc=@mysql_result($result,$i,"desc");
            
$cost=@mysql_result($result,$i,"cost");
            
$kind=@mysql_result($result,$i,"kind");
            
$img=@mysql_result($result,$i,"img");
            if (((
$i+1)%4)!=0) {
                
$page .= "<td style='width:25%;'><a href='shop.php?shop=item&buy={$id}'><img src='{$img}'></a><br />{$cost}</td>";
            }
            else {
                
$page .= "<td style='width:25%;'><a href='shop.php?shop=item&buy={$id}'><img src='{$img}'></a><br />{$cost}</td></tr><tr>";
            }
            
$i++;
        }
        if (
$i%4!=0) {
            
$page .= "</table>";
        }
        else {
            
$page .= "</tr></table>";
        } 
Reply With Quote