Jump to content

Help displaying an array


playaz

Recommended Posts

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 :)

Link to comment
https://forums.phpfreaks.com/topic/5490-help-displaying-an-array/
Share on other sites

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.


[code]
<?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
?>

[/code]

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.