View previous topic :: View next topic |
Author |
Message |
jonleow -
Joined: 29 Apr 2004 Posts: 48
|
Posted: Sun Jul 04, 2004 1:52 pm Post subject: database search |
|
|
hi, anyone here knows any websites or has any scripts that show how a search engine for mysql can be done? i want my users to be able to search for products in my database rather than to direct them to external websites.
thanks |
|
Back to top |
|
|
00squeaky -
Joined: 11 May 2004 Posts: 60
|
Posted: Mon Jul 05, 2004 4:50 am Post subject: |
|
|
yea. just the code i am about to give you is pre release: it is case sensitive.
Code: |
//FORM to be on separate page.
<form action="search.php" method=post>
<input name="query" value="Search Here!">
<input type="submit" value="Search!">
</form>
|
Code: |
//search engine 1.1 by 00s
$query = $HTTP_POST_VARS['query'];
//connect to your DB here...
$sql="select * from news";
$result = mysql_query($sql);
$rows = mysql_num_rows($result);
$searchi = str_word_count($query);
for ($i = 1; $i <=$rows; i++) {
$sql="select title,text from news where id='".$i."'";
$result= mysql_query($sql);
$row= mysql_fetch_assoc($result);
$searchj = str_word_count($row['title']);
$searchk = str_word_count($row['text']);
$qu1 = $searchi && $searchj;
$qu2 = $searchi && $searchk;
if (title
|
i am still working on it, but do as you may. _________________ Languages mastered:
HTML,GML,C,PHP,MYSQL (not really a language, but wtf) |
|
Back to top |
|
|
jonleow -
Joined: 29 Apr 2004 Posts: 48
|
Posted: Mon Jul 05, 2004 8:49 am Post subject: |
|
|
ok.. will try it out...thanks |
|
Back to top |
|
|
jonleow -
Joined: 29 Apr 2004 Posts: 48
|
Posted: Mon Jul 05, 2004 10:33 am Post subject: |
|
|
do u have the complete version of the script? |
|
Back to top |
|
|
jonleow -
Joined: 29 Apr 2004 Posts: 48
|
Posted: Mon Jul 05, 2004 10:38 am Post subject: |
|
|
do u have the complete version of the script? |
|
Back to top |
|
|
00squeaky -
Joined: 11 May 2004 Posts: 60
|
Posted: Wed Jul 07, 2004 1:41 am Post subject: |
|
|
not yet. actually, i had a brain freez and forgot i was supposed to be postikng my old script and ended up formulating a new one. but anyway...
Code: |
//case sensitive search code v1.0, by 00s
//removing this will result in inoperational code
$query = $HTTP_POST_VARS['query'];
//connect to your DB here using the mysql_connect
$sql="select * from news";
$result = mysql_query($sql);
$rows = mysql_num_rows($result);
echo"<table cellspacing=1 border=1>"
for ($i = 0; $i <= $rows; $i++) {
$sql=("select title,text from news where id='".$i"'");
$result = mysql_query($sql);
$row = mysql_fetch_assoc($result);
$ti = $row['title'];
$t = $row['text'];
if ($ti = $query){
echo "<tr><td bgcolor=maroon>$ti</td></tr>
<tr><td bgcolor=yellow>$text</td></tr><tr><td> </td></tr>";
}}
echo "</table>";
|
there. oh, and just to tell you, this is the version i concocted in a minute, so there are nno convinirence garuntees. (sp?) _________________ Languages mastered:
HTML,GML,C,PHP,MYSQL (not really a language, but wtf)
Last edited by 00squeaky on Thu Jul 08, 2004 8:48 am; edited 1 time in total |
|
Back to top |
|
|
masa -
Joined: 05 Apr 2004 Posts: 182 Location: Hong Kong
|
|
Back to top |
|
|
Anonymoose -
Joined: 09 Sep 2003 Posts: 2192
|
Posted: Wed Jul 07, 2004 6:06 pm Post subject: |
|
|
Searches a MySQL database. *sigh* |
|
Back to top |
|
|
00squeaky -
Joined: 11 May 2004 Posts: 60
|
Posted: Thu Jul 08, 2004 8:47 am Post subject: |
|
|
masa wrote: | what does it actually do? |
man, cant you read the topic title+ description?
and Amoose, what is the sigh for? i spent a whole minute thinking of that script! (:p) _________________ Languages mastered:
HTML,GML,C,PHP,MYSQL (not really a language, but wtf) |
|
Back to top |
|
|
Anonymoose -
Joined: 09 Sep 2003 Posts: 2192
|
Posted: Thu Jul 08, 2004 11:25 am Post subject: |
|
|
I wasn't sighing at the script ;D |
|
Back to top |
|
|
00squeaky -
Joined: 11 May 2004 Posts: 60
|
Posted: Mon Jul 12, 2004 10:45 pm Post subject: |
|
|
ok. it was just a misunderstanding. _________________ Languages mastered:
HTML,GML,C,PHP,MYSQL (not really a language, but wtf) |
|
Back to top |
|
|
jonleow -
Joined: 29 Apr 2004 Posts: 48
|
Posted: Tue Jul 13, 2004 10:51 am Post subject: |
|
|
im glad the misunderstanding has been cleared |
|
Back to top |
|
|
|