Author Topic: Showing results in rows of 3?  (Read 188 times)

Ellie

  • Regular Member
  • **
  • Posts: 39
  • Karma: 0
    • View Profile
Showing results in rows of 3?
« on: May 29, 2012, 09:53:00 AM »
I have been trying to do this for 3 days now, though i do not know how to word it.
 
 My page currently looks like this http://www.sketchedneo.com//shields.php
 
 Though i want the Shields to show in a row like this
 
 Shield                 Shield                 Shield
 css code            css code            css code
 html code            html code            html code
 direct url              direct url              direct url
 
 instead of
 
 Sheild
 css code
 html code
 direct url
 
  Sheild
 css code
 html code
 direct url
 
 
 An example of what I mean compared to my url is http://www.sunnyneo.com/shields.php
 
 
 
 My current code is.
 
PHP Code: [Select]
 $num mysql_num_rows(mysql_query("SELECT id FROM acshields WHERE checked = 1"));


if (
$num <= 0)
{
	
echo 
"


<p><center>

There are no acshields at this time :("
;
}
$sort mysql_query("SELECT * FROM acshields WHERE checked = 1 ORDER BY id");
while(
$sort2 mysql_fetch_array($sort))


{


 if(
$sort2[id]){

echo(
"

<p><table width=\"600\" height=\"154\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">
  <tr>
    <td width=\"192\" height=\"134\" style=\"border-top: 1pt solid black;border-left: 1pt solid black;border-right: 1pt solid black; background-color:#f4f4f4;\"><center>
   <img src=\"
$sort2[url]\">
    </center></td>
    <td width=\"408\" valign=\"middle\" style=\"border-top: 1pt solid black;border-right: 1pt solid black; background-color:#f4f4f4;\"><center>
    
    
    
    CSS Code: <br>
    <textarea><style>
#userinfo .contentModuleContent {
	
background-image: url(\"
$sort2[url]\");
	
background-repeat: no-repeat;
	
background-position: top right;
}
#userinfo .medText img {
	
visibility: hidden;
}
#userinfo .medText table table img {
	
visibility: visible;
}
</style> </textarea><p>


      HTML Code: <br>
    <textarea><img src=\"
$sort2[url]\">
    </textarea><p>
        URL: <br>
    <textarea>
$sort2[url]
    </textarea>  </center></td>
  </tr>
  <tr>
    <td height=\"20\" colspan=\"2\" style=\"border-top: 1pt solid black;border-bottom: 1pt solid black;border-left: 1pt solid black;border-right: 1pt solid black; background-color:#8cc7e3;\"><center>
      
$sort2[name] || Made by: $sort2[madeby]
    </center></td>
  </tr>
</table>



"
); }



}




 Can some please help me with the code i need so it will show my shields in a html table row of 3

Asaru

  • New Member
  • *
  • Posts: 6
  • Karma: 0
    • View Profile
Re: Showing results in rows of 3?
« Reply #1 on: May 29, 2012, 12:55:07 PM »
If I got it right, what about just doing kind of
Code: [Select]
while($sort2a = mysql_fetch_array($sort))
{
$sort2b = mysql_fetch_array($sort);
$sort2c = mysql_fetch_array($sort);
// and then something like
echo '<tr><td>'.$sort2a['img'].'<br>.'$sort2a['name'].'<br><textarea>.'$sort2a['css'].'</textarea></td>'.
'<td>'.$sort2b['img'].'<br>.'$sort2b['name'].'<br><textarea>.'$sort2b['css'].'</textarea></td>'.
'<td>'.$sort2c['img'].'<br>.'$sort2c['name'].'<br><textarea>.'$sort2c['css'].'</textarea></td></tr>';
}
Of course, you would need to do some checkups, if the rows exists (if not, mysql_fetch_array returns false). But imho it could work like that. I hope you know what I mean