If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > PHP > search script, witch functions ?

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 08-11-10, 13:28
newvbs_10 newvbs_10 is offline
Registered User
 
Join Date: Aug 2010
Posts: 1
search script, witch functions ?

Hello

I would like to build mini search system.
I have one column in DB,
i choose correct rows by "against match" query,
and i want to display result in short way.

Example should tell what I mean:

$searchString = "aaaa bbbb cccc";

result:
sdsdssdsd aaaa dsd sdsd sd aaaa bbbb dsdsd ... asas bbbb dsfe ...
dsdsd bbbb cccc dsdsd ... asas bbbb dsfe ....

It's like in google search, where desctription of site are show.

I will be glad for working script to do it
or just a helpful function, class etc.

Peace <3
Reply With Quote
  #2 (permalink)  
Old 08-23-10, 05:33
mhlinh mhlinh is offline
Registered User
 
Join Date: Aug 2010
Posts: 1
PHP Code:
<form name="search" method="post" action="<? echo $PHP_SELF; ?>">
<table width="331" border="0">
<tr>
<td width="76">Keyword:</td>
<td width="245">
<input type="text" name="keyword">
</font></td>
</tr>
</table>
<br>
<input type="submit" name="Submit" value="Search">
</form>


PHP Code:
<?php
mysql_connect("localhost","username", "password");
mysql_select_db("database");

if($Submit == "Search"){
echo"Tėm kiếm <b>$keyword</b><br><br>";

$result=mysql_query("SELECT * FROM `table` WHERE 1 AND `username` LIKE '$keyword%'");

while($row = mysql_fetch_array($result, MYSQL_ASSOC)){

printf("%s<br>", $row["username"]);
}
/* Kết quả */
mysql_free_result($result);
}
?>
Reply With Quote
Reply

Tags
class, function, php, script, search

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On