Jump to content


Photo

Help displaying an array


  • Please log in to reply
1 reply to this topic

#1 playaz

playaz
  • Members
  • PipPipPip
  • Advanced Member
  • 55 posts

Posted 22 March 2006 - 10:25 AM

Hi guys,

I am trying to get my array to display two items on each table row so its effectively two <td> tags. The effect I want is similar to how the "Technology partner" section looks on the the following site.

[a href=\"http://tinyurl.com/lemxb\" target=\"_blank\"]http://tinyurl.com/lemxb[/a]

If the array has more than two items it would need to make a new row <tr> - so each table row has 2 items and no more.

Can anyone help me out :)



#2 wisewood

wisewood
  • Members
  • PipPipPip
  • Advanced Member
  • 226 posts
  • LocationRotherham, England

Posted 22 March 2006 - 10:49 AM

No time to explain... but this is what i use to create the same effect.
"" if (($x%2 "" is the bit that does the business... if you wanted to increase your table columns to 3, 4, 5 or whatever... just replace the 2 with the number of columns you need.

Hope this helps you find a way to what you want to do.


<?php
$bareQuery = "SELECT * FROM My_Table";
$queryall = $bareQuery.$sorted;
$resultall = MYSQL_QUERY($queryall);
$numberall = mysql_Numrows($resultall);

if ($numberall==0) {
    echo "No Slackers Found !";
}
else if ($numberall>0) {
$x=0;
?>
<table class="content" align="center">
<?
while ($x<$numberall)
      {
           if (($x%2)==0) { $row="</tr><tr><td>"; } else { $row="<td>"; }
            
echo $row 
?>


wisewood: proven fact, I am both wise, and wooden.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users