crypto
12-18-2003, 10:34 PM
Ok I'v made a database in MySQL with all my address book in it and I'm trying to make the address book in PHP to easily be able to search it but my code isnt working my page with the form on works but the PHP page that searches the database and prints the resalts in the browser dosnt work below I have included my 'search.php'
<?php
require_once ('connect.php');
$query = "select concat(LAST_NAME, FIRST_NAME, INITIALS) as Name, concat(HOUSE_NO, STREET, POST_TOWN, POST_ZIP_CODE) as Address, concat(PHONE1, PHONE2, MOB1, MOB2) as Phone from names";
$result = @mysql_query ($query);
if ($result) {
echo '<table align="center" cellspacing="2" cellpadding="2">
<tr><td align="left"><b>Name</b></td><td align="left"><b>Address</b></td><td align="left"><b>Phone</b></td></tr>';
while ($row = mysql_fetch_array($result, YSQL_NUM)) {
echo "<tr><td align=\"left\">$row[0]</td><td align=\"left\">$row[1]</td></tr>\n";
}
echo '</table>';
mysql_free_result ($result);
} else {
echo '<p>The address list could not be found due to a system error. Sorry for any inconvenience.</p><p>' . mysql_error() . '</p>';
}
mysql_close();
?>
One thing i hope the code came up so you can see it. And can anyone please help me and tell me where I am going wrong.
Thankyou.
<?php
require_once ('connect.php');
$query = "select concat(LAST_NAME, FIRST_NAME, INITIALS) as Name, concat(HOUSE_NO, STREET, POST_TOWN, POST_ZIP_CODE) as Address, concat(PHONE1, PHONE2, MOB1, MOB2) as Phone from names";
$result = @mysql_query ($query);
if ($result) {
echo '<table align="center" cellspacing="2" cellpadding="2">
<tr><td align="left"><b>Name</b></td><td align="left"><b>Address</b></td><td align="left"><b>Phone</b></td></tr>';
while ($row = mysql_fetch_array($result, YSQL_NUM)) {
echo "<tr><td align=\"left\">$row[0]</td><td align=\"left\">$row[1]</td></tr>\n";
}
echo '</table>';
mysql_free_result ($result);
} else {
echo '<p>The address list could not be found due to a system error. Sorry for any inconvenience.</p><p>' . mysql_error() . '</p>';
}
mysql_close();
?>
One thing i hope the code came up so you can see it. And can anyone please help me and tell me where I am going wrong.
Thankyou.