HouseTbl
-HouseID (unique)
-HouseNum
-HouseStreet
-HouseCombined
PeopleTbl
-NameID (unique)
-NameLast
-NameFirst
ResidentTbl
-ResidentID (unique)
-Name_ID
-House_ID
Bring in a variable from a link that you want to be the first letter of the last name. Call it $var.
Code: Select all
<?php
$result = mysql_query("SELECT *
FROM PeopleTbl
INNER JOIN ResidentTbl ON (PeopleTbl.NameID = ResidentTbl.Name_ID)
WHERE SUBSTRING(NameLast,1,1) = $var");
?>
Unfortunately, as soon as I go back to the HTML and try to fetch the result, it gives me an error:
mysql_fetch_array(): supplied argument is not a valid MySQL result resource in ...on line 27
Line 27 starts the fetch that follows:
Code: Select all
<?php
while ($row = mysql_fetch_array($result) ) {
echo $row['NameLast']." ".$row['NameFirst'];
echo "<br>";
}
?>