database search

 
Post new topic   Reply to topic    Aprelium Forum Index -> PHP
View previous topic :: View next topic  
Author Message
jonleow
-


Joined: 29 Apr 2004
Posts: 48

PostPosted: Sun Jul 04, 2004 1:52 pm    Post subject: database search Reply with quote

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 View user's profile Send private message MSN Messenger
00squeaky
-


Joined: 11 May 2004
Posts: 60

PostPosted: Mon Jul 05, 2004 4:50 am    Post subject: Reply with quote

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 View user's profile Send private message
jonleow
-


Joined: 29 Apr 2004
Posts: 48

PostPosted: Mon Jul 05, 2004 8:49 am    Post subject: Reply with quote

ok.. will try it out...thanks
Back to top View user's profile Send private message MSN Messenger
jonleow
-


Joined: 29 Apr 2004
Posts: 48

PostPosted: Mon Jul 05, 2004 10:33 am    Post subject: Reply with quote

do u have the complete version of the script?
Back to top View user's profile Send private message MSN Messenger
jonleow
-


Joined: 29 Apr 2004
Posts: 48

PostPosted: Mon Jul 05, 2004 10:38 am    Post subject: Reply with quote

do u have the complete version of the script?
Back to top View user's profile Send private message MSN Messenger
00squeaky
-


Joined: 11 May 2004
Posts: 60

PostPosted: Wed Jul 07, 2004 1:41 am    Post subject: Reply with quote

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>&nbsp;</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 View user's profile Send private message
masa
-


Joined: 05 Apr 2004
Posts: 182
Location: Hong Kong

PostPosted: Wed Jul 07, 2004 2:28 pm    Post subject: Reply with quote

what does it actually do?
_________________
Visit http://web26.hopto.org:443/ please help me make my site better http://web26.hopto.org:443/
Back to top View user's profile Send private message Send e-mail Visit poster's website
Anonymoose
-


Joined: 09 Sep 2003
Posts: 2192

PostPosted: Wed Jul 07, 2004 6:06 pm    Post subject: Reply with quote

Searches a MySQL database. *sigh*
Back to top View user's profile Send private message
00squeaky
-


Joined: 11 May 2004
Posts: 60

PostPosted: Thu Jul 08, 2004 8:47 am    Post subject: Reply with quote

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 View user's profile Send private message
Anonymoose
-


Joined: 09 Sep 2003
Posts: 2192

PostPosted: Thu Jul 08, 2004 11:25 am    Post subject: Reply with quote

I wasn't sighing at the script ;D
Back to top View user's profile Send private message
00squeaky
-


Joined: 11 May 2004
Posts: 60

PostPosted: Mon Jul 12, 2004 10:45 pm    Post subject: Reply with quote

ok. it was just a misunderstanding.
_________________
Languages mastered:
HTML,GML,C,PHP,MYSQL (not really a language, but wtf)
Back to top View user's profile Send private message
jonleow
-


Joined: 29 Apr 2004
Posts: 48

PostPosted: Tue Jul 13, 2004 10:51 am    Post subject: Reply with quote

im glad the misunderstanding has been cleared
Back to top View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> PHP All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB phpBB Group