this searches for the name of the person using the keyword
Code: Select all
<?php
$sql = mysql_query("SELECT DISTINCT personID, personFirstName, personMiddleInitial, personLastName
FROM person join student
ON person.personid = student.studentID
WHERE personFirstName LIKE '%keyword%' OR personMiddleInitial LIKE '%keyword%' OR personLastName LIKE '%keyword%'");
if(mysql_num_rows($sql)==0)
{echo "<tr> <td colspan=\'2'\ style=\"width: 40em;\"> No records found! </td> </tr>";}
else
{
while($row=mysql_fetch_array($sql))
{
$firstname = $row['personFirstName'];
$lastname = $row['personLastName'];
$middleinitial = $row['personMiddleInitial'];
$pid = $row['personID'];
echo "<tr>";
echo "<td> ". $firstname . " " . $middleinitial . " " . $lastname . "</td>";
echo "<td> <a href=\"viewstudentaccountabilities.php?pid=$pid\" style=\"color:#0066cc;\"> View Accountabilities </td>";
echo "</tr>";
}
}
?>
Code: Select all
SELECT DISTINCT personID, personFirstName, personMiddleInitial, personLastName
FROM person JOIN student
ON person.personid = student.studentID
WHERE personFirstName LIKE '%keyword%' OR personMiddleInitial LIKE '%keyword%' OR personLastName LIKE '%keyword%'
But when I run it in the php file, it always returns 0 results..
I removed once the mysql_num_rows to see if it causes the error but no, it still returns 0 results... what could be the problem with this code..
btw, im using wampserver 2.0e.. (php 5.2.7 and mysql 5.1.30)