Cum sa faci un ‘search’
Am cautat ceva vreme cum anume sa fac un script in php de cautare.
Dupa cum ma asteptam nu este prea greu.
Mai intai creati un search.php dupa cum urmeaza
query($query);
/*number of rows found*/
$num_results = $result->num_rows;
echo ‘
Found: ‘.$num_results.’
‘;
/*loops through results*/
for ($i=0; $i <$num_results; $i++) { $num_found = $i + 1; $row = $result->fetch_assoc();
echo “$num_found. “.($row['tablerow']).”
“;
}
/*free database*/
$result->free();
$dbconn->close();
?>
Apoi creezi un html cu
<html>
<head>
<title>Search Test</title>
</head>
<body topmargin=”0″ leftmargin=”0″>
<form action=”search.php” method=”post”>
Search Term <input type=”text” name=”searchterm”><br />
<input type=”submit” value=”Search”>
</form>
</body>
</html>
Cam asta e tot. Va recomand de asemenea sa vizitati biblia php.
Scrieri pe aceeasi tema:

