New to PHP and MySQL, have heard amazing things about this website from Leo Laporte and others. I am using a extremely basic PHP script to search a MySQL database of peoples names. I was wondering how I can have the search supply an error if there no one by that name in the database.
</p><?php
mysql_connect ("mysql.mydomain.us", "pnq_1","passwordremoved") or die (mysql_error());
mysql_select_db ("pnq_soldiers");
$term = $_POST['term'];
$sql = mysql_query("select * from test_database where LN like '%$term%'");
while ($row = mysql_fetch_array($sql)){
echo 'Last Name: '.$row['LN'];
echo '<br/> First Name: '.$row['FN'];
echo '<br/> Middle Initial: '.$row['MI'];
echo '<br/> Rank: '.$row['RNK'];
echo '<br/> Company: '.$row['CO'];
echo '<br/> Platoon: '.$row['PL'];
echo '<br/> Roster Number: '.$row['RN'];
echo '<br/><br/>';
}
?>