Problem with getting all info from database query.
Posted: Tue Jun 10, 2003 11:01 am
Here is snipet of my code:
I know this code isn't correct, mainly because it doens't work, but I can't figure out how to get it to grab each record from the database.
I tried to do this and send the information into an array:
But yet again, it would only output a single record from the database.
If you can not visualize what I am trying to do, you can see the single record output I have created at:
http://www.immortalsix.com/alumni.php
Thanks for any help!
Code: Select all
$sql = "SELECT * FROM sda_alumni";
$sql_result = mysql_query($sql) or die ("could not query the database");
$row = mysql_fetch_array($sql_result);
$fn = $rowї'first_name'];
$ln = $rowї'last_name'];
$bn = $rowї'bond_number'];
$ht = $rowї'current_hometown'];
$cs = $rowї'current_state'];
$yg = $rowї'year_graduated'];
?>
<table border=1>
<tr>
<td><b>First Name</b></td>
<td><b>Last Name</b></td>
<td><b>Bond Number</b></td>
<td><b>Hometown</b></td>
<td><b>State</b></td>
<td><b>Year Graduated</b></td>
</tr>
<tr>
<td><?php echo ($fn); ?></td>
<td><?php echo ($ln); ?></td>
<td><?php echo ($bn); ?></td>
<td><?php echo ($ht); ?></td>
<td><?php echo ($cs); ?></td>
<td><?php echo ($yg); ?></td>I tried to do this and send the information into an array:
Code: Select all
foreach(array($fn, $ln, $bn, $ht, $cs, $yg) as $alumni) {
print "$alumni\n";
}If you can not visualize what I am trying to do, you can see the single record output I have created at:
http://www.immortalsix.com/alumni.php
Thanks for any help!