I would like your help to fix the problem I have with coding you will see below.
I tried tp creat a search interface to help visters to find information what they are looking form,
To achieve this task I thought this code which I found from web might solved the problem. However I have still problems.
[B] Coding starting here[/B]
<?php
require_once("login.php");
?>
<?php
if ($authorized) {
// set database access
$host="sql200.byethost8.com"; // Host name
$username="b8_2391616"; // Mysql username
$password="RHODES"; // Mysql password
$db_name="b8_2391616_bzstable"; // Database name
$tbl_name="bzs"; // Table name
// Connect to server and select databse.
$select = $_POST['contact_name'];
$searchdb = $_POST['searchdb'];
// make the query
$query = "SELECT contact_name, category, organisation, country, city, website , phone, email"
FROM bzs
WHERE $select LIKE '%$searchdb%'";
$result = @mysql_query($query); // run query
$num = @mysql_num_rows($result);
if ($num > 0) {
echo "<p style=\"text-align: center\"><strong>There are currently $num of results.</strong></p>";
} else {
echo "<p style=\"text-align: center\"><strong>There are no matches in the database.</strong></p>";
}
// if ($result) { // If it ran OK, display the records.
// Table header.
echo '<table align="center" cellspacing="10" cellpadding="15">
<tr>
<td align="left"><b>contact name</b></td>
<td align="left"><b>category</b></td>
<td align="left"><b>organisation</b></td>
<td align="left"><b>country</b></td>
<td align="left"><b>city</b></td>
<td align="left"><b>website</b></td>
<td align="left"><b>phone</b></td>
<td align="left"><b>email</b></td></tr>';
// Fetch and print all the records.
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
echo '<tr><td align="left">' . $row['contact_name'] . '</td>
<td align="left">' . $row['category'] . '</td>
<td align="left">' . $row['organisation'] . '</td>
<td align="left">' . $row['country'] . '</td>
<td align="left">' . $row['city'] . '</td>
<td align="left">' . $row['website']
<td align="left">' . $row['phone'] . '</td>
<td align="left">' . $row['email'] . '</td></tr>';
}
echo '</table>';
// Closing connection
// Closing query
//mysql_close($query);
} else {
echo "<p> You must provide a valid username and password to use this</p>";
echo "<a href=\"index.php\">Back</a>";
}
?>
</body>
Syntax highlighting powered by GeSHi
PHP CODING FINISH HERE
Thanks
Resoum