I am new to php
Can anybody please help cant get an array to go across columns only to run down one after the other
here is the code
<?
include('config.php');
//Open Connection to database
$db = mysql_connect("$hostname", "$username","$password");
mysql_select_db("$database",$db);
?>
<?
$result = mysql_query("SELECT * FROM models", $db);
while ($product=mysql_fetch_array($result))
{
?>
<table width="90%" border="1" cellspacing="0" cellpadding="0">
<tr>
<td><?=$product[name]?></td>
<td><?=$product[age]?></td>
</tr>
</table>
<?
}
?>
here is the result
http://www.dave-ward.co.uk/model/model.php
help with array in columns
Moderator: General Moderators
-
JPlush76
- Forum Regular
- Posts: 819
- Joined: Thu Aug 01, 2002 5:42 pm
- Location: Los Angeles, CA
- Contact:
Code: Select all
<?php
echo '<table width="90%" border="1" cellspacing="0" cellpadding="0">';
echo '<tr> ';
$c = 1;
while ($product=mysql_fetch_array($result))
{
if($c == 2)
{
echo '</tr><tr>';
}
echo '<td>'.$product[name].'</td> ';
$c++;
}
</tr>
</table>
?>