Cum sa faci un ‘search’

{ Posted on Sep 19 2009 by StiiCeva }
Tags : ,
Categories : internetIT

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:

  1. Referate – grozave
  2. Speed – download filmul
  3. restrangerea url-urilor! :)
  4. HTML Intro – Tags in HTML
  5. Dictionar

Post a Comment


Referrer of this page =

Hello 2