I am having problems with this code ( This is all new to me so go easy lol...)
I am trying to get the code below to display records for all ( I only have two records in my table) by surname. If I just have
$result = @mysql_query("SELECT surname FROM support_call ");
This works okay and displays the surnames in the two records.But when I add a WHERE as I want to get data from all fileds ( I have only added firstname for now) as below I get a blank page
$result = @mysql_query("SELECT surname,firstname FROM support_call WHERE surname = '$surname'");
if (!$result) {
exit('<p>Error performing query: ' . mysql_error() . '</p>');
}
Can someone put me out of my misery please .Full page below
<?php
// Connect to the database server
$dbcnx = @mysql_connect('localhost', 'root', 'password');
if (!$dbcnx) {
exit('<p>Unable to connect to the ' .
'database server at this time.</p>');
}
// Select the support database
if (!@mysql_select_db('ict_support')) {
exit('<p>Unable to locate the ict_support ' .
'database at this time.</p>');
}
?>
<p>Here are all the calls in our database:</p>
<blockquote>
<?php
// Request the text of all the calls
$result = @mysql_query("SELECT surname,firstname FROM support_call WHERE surname = '$surname'");
if (!$result) {
exit('<p>Error performing query: ' . mysql_error() . '</p>');
}
// Display the text of each call in a paragraph
while ($row = mysql_fetch_array($result)) {
echo '<p>' . $row['surname'] . '</p>';
}
?>