listing based on name
Posted: Wed Apr 12, 2006 9:39 am
My question is, I want to display results that are attributed to someones last name. The code below works great when "lname" is replaced with "id" but I'm not looking for results for a single record but multiple.
This is the link from the homepage:
This is part of comp.php. $fname is just there just to keep it simple and see if anything is pulling.
This is the link from the homepage:
Code: Select all
<a href="comp.php?name=$lname">$company</a>This is part of comp.php. $fname is just there just to keep it simple and see if anything is pulling.
Code: Select all
<?php
mysql_connect ('server', 'name', 'pass') or die ('Error connecting to mysql');
mysql_select_db (datebase);
$lname = $_GET['lname'];
$query = "SELECT * FROM job WHERE lname='$lname'";
$result = mysql_query($query) or die('Error : ' . mysql_error());
$row = mysql_fetch_array($result, MYSQL_ASSOC);
if (mysql_errno() != 0) {
echo 'Error: ' . mysql_error() . '<br/>';
}
$fname = $row['fname'];
echo $fname;
mysql_close();
?>