I am trying to call each record in a user database table and display them in a member directory for my site and I only get the first users information for every record in my table.
<?php
$query = "SELECT id FROM users ORDER BY company ASC";
$result = mysql_query($query);
confirm_query($result);
$row = mysql_fetch_array($result);
foreach($row as $id){
$query = "SELECT name, address, city, state, zip, phone, fax, email, company FROM users WHERE id = $id";
$result = mysql_query($query);
confirm_query($result);
$row = mysql_fetch_array($result);
$name = $row['name'];
$email = $row['email'];
$company = $row['company'];
?>
<td valign="top" style="font-size:12px; text-align:center">
<table>
<tr>
<td><?php echo $name; ?></td>
</tr>
<tr>
<td><?php echo $company; ?></td>
</tr>
<tr>
<td><?php echo $email; ?></td>
</tr>
</table>
</td>
<?
}
?>
I have tried doing a while loop and get the right id numbers back from the initial query but I have frankly never been able to get foreach right and I just want to finally do it. Any help would be appreciated.