|
Example of the Procedures <?php $localhost =
"localhost"; $username =
"XXXXXXXX"; $password =
"YYYYYYYY"; $database_name =
"DDDDDDD"; $table_name =
"Category_Info";
//database table name $table_name2 =
"Home_site_Info"; $query_field =
"Cat_keywords";
//database table field name $query_string =
$T1; //html form text box name # Connect to your MySQL database server mysql_connect ($localhost, $username, $password) or die ('We cannot connect
to the database.'); # Select a default database to work with mysql_select_db ($database_name) or die ('We have some difficultes
to connect to the database. Sorry for the inconvenience
for you'); # SQL query on tables in database $query = "SELECT h.H_title, h.H_description, h.H_score,
h.H_visit, h.H_URL FROM $table_name c, $table_name2 h WHERE $query_field ='$query_string'AND c.H_URL
= h.H_URL "; $query_result_handle
= mysql_query ($query) or die ('We have some difficultes
to connect to the database'); #make sure that we recieved some data from
our query $num_of_rows = mysql_num_rows
($query_result_handle) or die ("Sorry, no matched
record for <b>$query_string</b><br>"); print "Find $num_of_rows matched sites for
$query_string in the web"; # use mysql_fetch_row to retrieve the
results for ($count = 1; $row = mysql_fetch_row
($query_result_handle); ++$count) { print " $row[4], $row[0]
<br>";
//hyperlinked title print " $row[1]...
<br>";
//home page description print "Point: $row[2];
Visited: $row[3] <br>"; print "$row[4] "; //home page address URL } ?> |