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
please help array in columns
Moderator: General Moderators
Not sure this is what you wanted, but if you move the table and tablerow start outside the while-loop, you should get a bunch of tabledata-fields following each other...
Code: Select all
<!-- Moved <table> and <tr> to the outside -->
<table width="90%" border="1" cellspacing="0" cellpadding="0">
<tr>
<?php while ($product=mysql_fetch_array($result)) { ?>
<!-- Looping just <td>'s -->
<td><?=$product[name]?></td>
<td><?=$product[age]?></td>
<? } ?>
<!-- Moved </table> and </tr> to the outside -->
</tr>
</table>