Why does the loop stop?
Posted: Mon Apr 17, 2006 10:39 am
Why is my loop stopping when it hits the first result? **note this a simplified version of the code just for the question
This code is on a page linked from
This code is on a page linked from
Code: Select all
http://localhost/~administrator/job/comp.php?name=ViceCode: Select all
<?php
mysql_connect ('local', 'name', 'pass') or die ('Error connecting to mysql');
mysql_select_db (db);
$name = $_GET['name'];
$query = "SELECT * FROM job WHERE lname='$name' ORDER BY id desc";
$result = mysql_query($query);
mysql_query($query) or die ('cannot retrieve');
$row = mysql_fetch_array($result, MYSQL_ASSOC);
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
echo $row['company'];
}
mysql_free_result($result);
?>