All pastes #945815 Raw Edit

phpsearchresult

public php v1 · immutable
·published 2008-03-17 05:56 UTC
rendered paste body
<HTML><HEAD> <TITLE>ABC Collage: search results</TITLE></HEAD><BODY> <H2>Search results</H2> <BR> <?php       $link = "<BR><BR><A HREF='SearchForm.html'>Click here to go back to the search page.</A>";	// remove whitespace from user input	$name = trim($name);	// if user input is empty, give error message and exit	if (!$name) {		echo "No search term given.";		echo $link;		exit;	}	// connect to database and select database 'vinyldealers'	$db = mysql_connect("localhost");	mysql_select_db("std", $db);	// find all records in 'stdtb1' table where data in the 'stdnames' field	// contains the string input by the user on the SearchForm.html page	$query = "SELECT stdtb1 FROM stdtb1 WHERE stdname LIKE '%".$sname."%'";	$result = mysql_query($query);	// if no results are returned from the query, give error message and exit	if (mysql_num_rows($result) == 0) {		echo "Sorry, no matching results.";		echo $link;		exit;	}	// return the data and display it	while ($record = mysql_fetch_assoc($result)) {		while (list($fieldname, $fieldvalue) = each ($record)) {			echo $fieldname.": <B>".$fieldvalue."</B><BR>";		}		echo "<BR>";	}		// include the hyperlink to name_sch.html	echo $link; ?></BODY></HTML>