Pages: 12Next
Current Page: 1 of 2
search into database
Posted by: kathierry2106 (196.44.244.---)
Date: February 27, 2008 09:30AM

Hello Steven and u'all!
with ur code i have used one field and search into database
here is the error I got

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '. &&' at line 1
SELECT * from book where MATCH(Title) AGAINST ('%breman%'). &&

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\wamp\www\LIBRARY\check_database.php on line 48
No Results were found.

any help will be kind
tks

----------------------------------------------------
the kind of search i am looking for is
a search with will search into
my database "library_bank" with 3 tables : book, journal, cd
***
<html>
<head><title>Searching the Database_library</title>
</head>
<body bgcolor=#ffffff>
<CENTER><h2>Searching the Database Library</h2>
</CENTER>

<form method="post" action="check_database.php3">
<table width=90% align=center>
<tr><td>search for BOOK, JOURNAL, CD-ROM,...:</td>
<td><input type=text name='search' size=60 maxlength=255></td></tr>
<td></td>

<td><input type=submit VALUE='SEARCH'></td></tr>
</table>
</form>

</body>
</html>

*****
I want php script that will Retrieve all the records that match to the the search string am entering in the form of search

Thanks in advance

best reagards
Thierry

Options: ReplyQuote
Re: search into database
Posted by: stevenmartin99 (---.b-ras1.blp.dublin.eircom.net)
Date: February 27, 2008 09:36AM

lol if u only want one box


do u want it to search all the rows?

for example a row in database


1 book author publisher


if i search for "book " it will find row 1

if i search for "book author " it will still find row 1?

Options: ReplyQuote
Re: search into database
Posted by: valter (---.lsn.estpak.ee)
Date: February 27, 2008 09:46AM

Give a try for three querys

$array1 = query(SELECT title as Name FROM book WHERE title LIKE '%breman%'"winking smiley;
$array2 = query(SELECT cd_title as Name FROM cd WHERE cd_title LIKE '%breman%'"winking smiley;
$array3 = query(SELECT journal_title as Name FROM journal WHERE journal_title LIKE '%breman%'"winking smiley;

After that:

$result = array_merge($array1, $array2, $array3 );

Note that this is not a working code but idea smiling smiley . I ma sure there is a way to do that whith one query but it is a bit more complex.

Maybe even better solution is to put cd, book and journal ínto one tabel and make an adittional type column



Edited 2 time(s). Last edit at 02/27/2008 09:58AM by valter.

Options: ReplyQuote
Re: search into database
Posted by: stevenmartin99 (---.b-ras1.blp.dublin.eircom.net)
Date: February 27, 2008 10:23AM

i will write the script for u


but i need to know wat columns you have in your data base and the name of the database

Options: ReplyQuote
Re: search into database
Posted by: kathierry2106 (196.44.244.---)
Date: February 27, 2008 10:57AM

the name of database "library_bank"
the 3 tables have same collumns
such as:
table:
book
SQL Statement of the table:"book" same as journal and CD-ROM

TABLE `library_bank`.`book`
(`id` INT( 21 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`Author` VARCHAR( 255 ) NOT NULL ,
`Title` VARCHAR( 255 ) NOT NULL ,
`Publisher` VARCHAR( 255 ) NOT NULL ,
`Keywords` VARCHAR( 255 ) NOT NULL
) ENGINE = InnoDB

so, i want to search into mysql database
when I am entering the word in search box and retrieve all the recors that matchs with this word
(for example in search field
I enter: Thierry) and i retrieve all row where thierry is:
or I enter in search field
Thierry (space) IPv6 and i will found the record where Thierry and IPv6 row are

Thank u

Options: ReplyQuote
Re: search into database
Posted by: kathierry2106 (196.44.244.---)
Date: February 27, 2008 01:35PM

hello steven!
how u doing"

hoping 2 hearing from u !

Options: ReplyQuote
Re: search into database
Posted by: stevenmartin99 (---.b-ras1.blp.dublin.eircom.net)
Date: February 27, 2008 01:40PM

sorry. ill have it posted in 2 hours. busy at the moment sorry

Options: ReplyQuote
Re: search into database
Posted by: stevenmartin99 (---.b-ras1.blp.dublin.eircom.net)
Date: February 27, 2008 05:33PM

-------------------------------------------------------------------------------------------
<?php
$search= $_POST['search'];
$searchwords = explode(" ","$search"winking smiley;
foreach ($searchwords as $word)
{$searchstring= $searchstring.' +'.$word;}
$tablelist = array(1 => 'book', 'cdrom', 'journal');
MySQL_connect("localhost", "root"winking smiley;
MySQL_select_db("library_bank"winking smiley;
foreach ($tablelist as $table){
$query = "SELECT * from $table Where MATCH(author,title,publisher,keywords) AGAINST ('$searchstring' IN BOOLEAN MODE)";
$result=mysql_query($query);}
if(!$result){echo MySQL_error()."<br>$data<br>";}
if(MySQL_num_rows($result) > 0)
{echo "<table border=1 >";
echo "<tr><td>Author</td><td>Title</td><td>Publisher</td><td>Keywords</td></tr>";
foreach ($tablelist as $table)
{ $query = "SELECT * from $table Where MATCH(author,title,publisher,keywords) AGAINST ('$searchstring' IN BOOLEAN MODE)";
$result=mysql_query($query);
while($row = MySQL_fetch_array($result))

{ echo "<tr><td>{$row['author']}</td>";
echo "<td>{$row['title']}</td>";
echo "<td>{$row['publisher']}</td>";
echo "<td>{$row['keywords']}</td></tr>";}}
echo "</table>";
}
else {echo "No Results were found.<br>";}
echo "<br>";
?>

<a href='search.php'>back</a>


--------------------------------------------------------------------------------


please note the words author title publisher and keyword in my script are all lowercase. make sure this matches


and the table names i have in it $tablelist = array(1 => 'book', 'cdrom', 'journal');


change them again if different


all you need to do is change your tables to use MyISAM instead of INNODB

and turn on full text support

if you dunno how to do that just ask

Options: ReplyQuote
Re: search into database
Posted by: kathierry2106 (196.44.244.---)
Date: February 28, 2008 12:39PM

hello Steven and 'all
tks again but
I got this error while i am running codes

""
The used table type doesn't support FULLTEXT indexes

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\wamp\www\LIBRARY\search_steven2.php on line 13
No Results were found.

back
"
I think it's a problem of full text support
all my tables are in myisam engine, so how to turn on full text support? pls

Options: ReplyQuote
Re: search into database
Posted by: kathierry2106 (196.44.244.---)
Date: February 28, 2008 01:20PM

hello Steve
tks
I managed to turn on full text suport

tks
it is so kind from u

~~~~~~~~
all the best
Thierry

Options: ReplyQuote
Re: search into database
Posted by: stevenmartin99 (---.b-ras1.blp.dublin.eircom.net)
Date: February 28, 2008 03:46PM

no problem

Options: ReplyQuote
Re: search into database
Posted by: kathierry2106 (196.44.244.---)
Date: February 28, 2008 04:21PM

Hi Steven
tks the search code is working without error

but it search for only exactelly simulary words, iz there a way i can get a word when I enter a part of that word
i.e I want search to select " Thierry" when i enter " thier" or hierry
and return resullts where thierry is in database.

Tks again,

Options: ReplyQuote
Re: search into database
Posted by: stevenmartin99 (---.b-ras1.blp.dublin.eircom.net)
Date: February 28, 2008 04:24PM

haha ok but wat i gave you is wat you sed u wanted..



its a totally different search that you want. instead of "match against" u need "like"


ill write it up in a few mins

Options: ReplyQuote
Re: search into database
Posted by: kathierry2106 (196.44.244.---)
Date: February 29, 2008 08:33AM

cool
so do i have to change
"match against" with like
??

nice day
Thierry

Options: ReplyQuote
Re: search into database
Posted by: kathierry2106 (196.44.244.---)
Date: March 03, 2008 11:42AM

hello Steve and 'all
hope u're fine

how to change "match against" with "like"

the search code is working without error but it is retrieving only records in one filed
in Author filed

is there anyway to search the content of the word not only exactelly simulary words,
ex:
i.e I want search to select " Thierry" when i enter " thier" or hierry
and return resullts where thierry is in database.

can i also combine
ex:Author "thierry" with its title "IPv6"
when I will search " thierry (space) IPv6
it wil return the results where
|auth| |Title|
thierry Ipv6
are in my database

so kind from ur help

Options: ReplyQuote
Re: search into database
Posted by: yfastud (Moderator)
Date: March 03, 2008 02:45PM

Hi guys

I don't want to be mean or rude or anything, so this is just a friendly reminder ;-)

@ kathierry2106
You get paid to do your job, so you should get a book and learn how to do it. If it's time matter and you're afraid you can not get it done in time, you should hire somebody to do it for you instead asking for help w/o paid. If this is not job related, and you just simply like to learn, you should ask for tips instead

@ stevenmartin99
Help people is a good thing and I really appreciate it; however, this is not wamp problem so if you like to help him, you guys should exchange your matter through your emails instead posting here. BTW, instead writing the whole codes for him, you should give him tips so he has ability to learn more how to write codes himself. Just my 2 cents ;-)

Thank you ;-)

Have fun,

FREE One A Day
FREE Photo
FREE Games
FREE Websites
FREE Portable GPS
FREE WAMP Guides



Edited 1 time(s). Last edit at 03/03/2008 03:33PM by yfastud.

Options: ReplyQuote
Re: search into database
Posted by: stevenmartin99 (---.b-ras1.blp.dublin.eircom.net)
Date: March 03, 2008 06:04PM

no yfastud i agree with you . thats why i didnt post this backup.

Options: ReplyQuote
Re: search into database
Posted by: yfastud (Moderator)
Date: March 03, 2008 06:13PM


Options: ReplyQuote
Re: search into database
Posted by: kathierry2106 (196.44.244.---)
Date: March 04, 2008 08:48AM

tks yfastud

u right,
by getting all codes then "copy" and "paste" into my macromedia dreamweaver
I ain't get more skills in the filed

so, as i posted my query
gimme more tips or if u can recomend me some free books
send me the link so that i can right any codes by understanding well

smiling smiley thank you

best regards

------------------------------------------------------------------------

I got also another problems with wamp
how can configure it so that it can be work as a server over local area network??
I am reading the config files of "httpd"
on the local area network

if i change online or add
# If your host doesn't have a registered DNS name, enter its IP address here.
#
ServerName localhost:80

into
# If your host doesn't have a registered DNS name, enter its IP address here.
#
ServerName localhost:80
ServerName MyWebsiteName:80

and save the change will it work on the web browser Ie7

Options: ReplyQuote
Re: search into database
Posted by: yfastud (Moderator)
Date: March 04, 2008 02:58PM

About tips, I thought Steven already suggested you to try like instead match and against

About books, I have some ebooks, 1 from Luke & Willing the authors I like, I was using before I've got my BS degree like 5yrs ago; the concepts are good but some syntax might not up to date, so if you want them, I can email them to you. BTW, google for free php ebook will result a lot and here is 1 ;-)

[www.onlinecomputerbooks.com]

Have fun,

FREE One A Day
FREE Photo
FREE Games
FREE Websites
FREE Portable GPS
FREE WAMP Guides

Options: ReplyQuote
Pages: 12Next
Current Page: 1 of 2


Sorry, only registered users may post in this forum.