Forum Moderators: coopster

Message Too Old, No Replies

displaying search results in double column table

php / mysql

         

jamie

4:30 pm on Apr 22, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



i am searching a mysql db and wish to display the results in a double column table

<table>
<tr>
<td>Result 1</td>
<td>Result 2</td>
<tr>
<tr>
<td>Result 3</td>
<td>Result 4</td>
<tr>
...etc

i am currently using a while statement which prints out one column of results

while ($row= mysql_fetch_array($result))
{
$name = $row["name"];
$url = $row["url"];
echo "<table width=\"300\"><tr>\n";
echo "<td><b><a href=\"".$url."\">".$name."</a></b></td>\n";
echo "</tr></table>";
}

and i haven't a clue about how to format these into two columns? ;-)

thankful for any suggestions!

dmorison

5:30 pm on Apr 22, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



echo "<table width=\"300\">

$i=0;

while ($row= mysql_fetch_array($result))
{
$name = $row["name"];

$url = $row["url"];

if (!($i % 2)) echo "<tr>";

echo "<td><b><a href=\"".$url."\">".$name."</a></b></td>\n";

if ($i % 2) echo"</tr>";

$i++;
}
if ($i % 2) echo "<td>&nbsp;</td></tr>";

echo "</table>";

jamie

6:31 pm on Apr 22, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



dmorison - you star :-)

worked straight out of the tin. i shall enjoy taking it apart to understand it more fully.

many thanks!

dmorison

6:56 pm on Apr 22, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



No problem!