Rv: Showing search results with links ... sorry forgot to post php code
| From: | Juan Stiller | Date: | Thu, 29 Oct 2009 22:32:20 +0000 |
| Subject: | Rv: Showing search results with links ... sorry forgot to post php code | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-46604@lists.php.net to get a copy of this message | ||
Hi there i
got this php script that shows results when the user type letters in a searchbox,
stretching the results every time the user enters a new letter. But i would like every result shown,
to have a link to a specific html page, how can i do that. I mean i am using a small guestbook
example that i found there, that uses mysql php ajax to do the job of polling the results out of the
mysql database, but i have to implement this with a very large database that shows parts wich have
unique part number and i have more that 3500 parts so i dont know how to do this can anyone
point me the right direction?
Thanks
Juan
PS: Sorry this is the code
<?php
define(HOST, "localhost");
define(USER, "root");
define(PW, "root");
define(DB, "ymad");
$connect = mysql_connect(HOST,USER,PW)
or die('Could not connect to mysql server.' );
mysql_select_db(DB, $connect)
or die('Could not select database.');
$term = strip_tags(substr($_POST['search_term'],0, 100));
$term = mysql_escape_string($term);
$sql = "select nombre,telefono from directory where nombre like '%$term%' or telefono
like '%$term%' order by nombre asc";
$result = mysql_query($sql);
$string = '';
if (mysql_num_rows($result) > 0){
while($row = mysql_fetch_object($result)){
$string .= "<b>".$row->nombre."</b> - ";
$string .= $row->telefono."</a>";
$string .= "<br/>\n";
}
}else{
$string = "No matches!";
}
echo $string;
?>
Yahoo! Cocina
Encontra las mejores recetas con Yahoo! Cocina.
http://ar.mujer.yahoo.com/cocina/