I am recently building a website using database. I purchased domain from hostmonster (Apache based server) and set up a database and a TABLE through its control panel . I am sure my php code can access the database but I just can not use the code to search and display results from the TABLE content in the database. Anyone can help see whether the php code is wrong or possibly my table is not invalid. Thanks.
Here is the code for result.php
CODE
<?
$hostname = "localhost"; // Our DB server.
$username = "xxx"; // The username you created for this database.
$password = "xxx"; // The password you created for the username.
$usertable = "cust"; // The name of the table you made.
$dbName = "xxx"; // This is the name of the database you made.
MYSQL_CONNECT($hostname, $username, $password) OR DIE("DB connection unavailable");
@mysql_select_db( "$dbName") or die( "Unable to select database");
?>
<?
//error message (not found message)begains
$XX = "No Record Found, to search again please close this window";
//query table begins
$query = mysql_query("SELECT * FROM cust WHERE [color=#FF0000]the table[/color] LIKE '%$search%' LIMIT 0, 30");
while ($row = @mysql_fetch_array($query))
$variable1=$row["id"];
$variable2=$row["name"];
$variable3=$row["telephone"];
//table layout for results
print ("<tr>");
print ("<td>$variable1</td>");
print ("<td>$variable2</td>");
print ("<td>$variable3</td>");
print ("</tr>");
//below this is the function for no record!!
//end
?>
Here is the code for search form:
CODE
<form method="post" action="http://www.domainname/result.php" target="_blank">
<div align="center">
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td bordercolor="#000000">
<p align="center">
<select name="name" size="1">
<option value="name">Name</option>
<option value="telephone">Telephone</option>
<option value="birthday">Birthday</option>
</select> <input type="text" name="search" size="25"> <br>
Search database: <input type="submit" value="Go!!" name="Go"></p>
</td>
</tr>
</table>
</div>
</form>
Many thanks