[PHP-DB] search query
Hi I have a option box with values select name=prijsklasse class=bodyzwart id=prijsklasse option value=1 selectedLess than 150.000 option value=2tot 175.000 option value=3tot 200.000 option value=4tot 250.000 option value=5tot 300.000 option value=6tot 350.000 option value=7tot 400.000 option value=8More than 400.000 /select I need help when the user chose option value 3 till 200.000 than the query should search between 175.000 and 200.000 how to achive this Regards -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Search Query
On 18 December 2003 05:26, Ng Hwee Hwee wrote: Dear all, i need help with my search query statement.. what is wrong with my code? Nothing obvious that I can see, except a little inefficiency. Where do $keyword and $table come from? -- is this a register_globals issue? snip $word = split( , $keyword); $num_words = count($word); $word_str = ; $criteria = ; for ($i=0; $i$num_words; $i++) { if ($i) $word_str .= and colName like '%.$word[$i].%' ; else $word_str .= colName like '%.$word[$i].%' ; } $word_str .= and col2 = '$foo' ; $criteria .= $word_str ; I'd replace all of the above with: $criteria = colName like '% . str_replace(' ' , %' and colName like '% , $keyword) . %' . and col2 = '$foo' $table .= db_table; $query = select * from .$table. where .$criteria; /snip when i try to echo $query, i get --- select * from where and so of course MySQL gives me an error 1064 near ' where ' what happened? What's your error_reporting level? HAve you tried cranking it up to E_ALL to see if any relevant warnings are being generated that you're not currently seeing? Cheers! Mike - Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning Information Services, JG125, James Graham Building, Leeds Metropolitan University, Beckett Park, LEEDS, LS6 3QS, United Kingdom Email: [EMAIL PROTECTED] Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Search Query
thanx Mike for your help!! appreciatively, hh - Original Message - From: Ford, Mike [LSS] [EMAIL PROTECTED] To: 'Ng Hwee Hwee' [EMAIL PROTECTED]; DBList [EMAIL PROTECTED] Sent: Thursday, December 18, 2003 6:06 PM Subject: RE: [PHP-DB] Search Query On 18 December 2003 05:26, Ng Hwee Hwee wrote: Dear all, i need help with my search query statement.. what is wrong with my code? Nothing obvious that I can see, except a little inefficiency. Where do $keyword and $table come from? -- is this a register_globals issue? snip $word = split( , $keyword); $num_words = count($word); $word_str = ; $criteria = ; for ($i=0; $i$num_words; $i++) { if ($i) $word_str .= and colName like '%.$word[$i].%' ; else $word_str .= colName like '%.$word[$i].%' ; } $word_str .= and col2 = '$foo' ; $criteria .= $word_str ; I'd replace all of the above with: $criteria = colName like '% . str_replace(' ' , %' and colName like '% , $keyword) . %' . and col2 = '$foo' $table .= db_table; $query = select * from .$table. where .$criteria; /snip when i try to echo $query, i get --- select * from where and so of course MySQL gives me an error 1064 near ' where ' what happened? What's your error_reporting level? HAve you tried cranking it up to E_ALL to see if any relevant warnings are being generated that you're not currently seeing? Cheers! Mike - Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning Information Services, JG125, James Graham Building, Leeds Metropolitan University, Beckett Park, LEEDS, LS6 3QS, United Kingdom Email: [EMAIL PROTECTED] Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Search Query
Dear all, i need help with my search query statement.. what is wrong with my code? snip $word = split( , $keyword); $num_words = count($word); $word_str = ; $criteria = ; for ($i=0; $i$num_words; $i++) { if ($i) $word_str .= and colName like '%.$word[$i].%' ; else $word_str .= colName like '%.$word[$i].%' ; } $word_str .= and col2 = '$foo' ; $criteria .= $word_str ; $table .= db_table; $query = select * from .$table. where .$criteria; /snip when i try to echo $query, i get --- select * from where and so of course MySQL gives me an error 1064 near ' where ' what happened? thanx thanx! hwee
[PHP-DB] search query problem
hi i am making a simple search form how can i search more than one table for the same word i used a query and it failed here it is @ $db = mysql_connect("localhost");mysql_select_db("egycds"); $test_tr = mysql_query("select newdvd.date, newpcgames.date, olddvd.date, screener.date,newdvd.type, newpcgames.type, olddvd.type, screener.type,newdvd.name, newpcgames.name, olddvd.name, screener.name,newdvd.cds, newpcgames.cds, olddvd.cds, screener.cds,newdvd.downloader, newpcgames.downloader, olddvd.downloader, screener.downloader, where newdvd.name like '%".$word."%'or newpcgames.name like '%".$word."%' or olddvd.name like '%".$word."%' or screener.name like '%".$word."%'"); while ($record=mysql_fetch_array($test_tr)){ echo " TR bgColor=#475674 TD width=75 DIV align=centerFONT color=#ff"; echo stripslashes($record['date']) ; echo "/FONT/DIV/TD TD width=50 DIV align=leftFONT color=white"; echo stripslashes($record['type']) ; echo "/FONT/DIV/TD TDFONT color=#ffstrongnbsp;nbsp;A href=""> echo stripslashes($record['link']); echo "\" target=_new1"; echo stripslashes($record['name']); echo "/Anbsp;nbsp;/strong/FONT/TD TD width=40 DIV align=leftFONT color=#ffA href=""> echo stripslashes($record['subtitle']); echo "\""; echo stripslashes($record['cds']); echo "/FONT/DIV/TD TD width=50 DIV align=leftFONT color=#ffA href=""> echo stripslashes($record['downloaderlink']); echo "\""; echo stripslashes($record['downloader']); echo "/A/FONT/DIV/TD /TR "; } echo "/TBODY/TABLE"; can anyone help please. IncrediMail - Email has finally evolved - Click Here
[PHP-DB] search query problem
hi i am making a simple search form how can i search more than one table for the same word i used a query and it failed here it is @ $db = mysql_connect(localhost); mysql_select_db(egycds); $test_tr = mysql_query(select newdvd.date, newpcgames.date, olddvd.date, screener.date, newdvd.type, newpcgames.type, olddvd.type, screener.type, newdvd.name, newpcgames.name, olddvd.name, screener.name, newdvd.cds, newpcgames.cds, olddvd.cds, screener.cds, newdvd.downloader, newpcgames.downloader, olddvd.downloader, screener.downloader, where newdvd.name like '%.$word.%' or newpcgames.name like '%.$word.%' or olddvd.name like '%.$word.%' or screener.name like '%.$word.%'); while ($record=mysql_fetch_array($test_tr)){ echo TR onmouseover=\this.bgColor='00'\ onmouseout=\this.bgColor='475674'\ bgColor=#475674 TD width=75 DIV align=centerFONT color=#ff; echo stripslashes($record['date']) ; echo /FONT/DIV/TD TD width=50 DIV align=leftFONT color=white; echo stripslashes($record['type']) ; echo /FONT/DIV/TD TDFONT color=#ffstrongnbsp;nbsp;A href=\; echo stripslashes($record['link']); echo \ target=_new1; echo stripslashes($record['name']); echo /Anbsp;nbsp;/strong/FONT/TD TD width=40 DIV align=leftFONT color=#ffA href=\; echo stripslashes($record['subtitle']); echo \; echo stripslashes($record['cds']); echo /FONT/DIV/TD TD width=50 DIV align=leftFONT color=#ffA href=\; echo stripslashes($record['downloaderlink']); echo \; echo stripslashes($record['downloader']); echo /A/FONT/DIV/TD /TR ; } echo /TBODY/TABLE; can anyone help please. _ STOP MORE SPAM with the new MSN 8 and get 2 months FREE* http://join.msn.com/?page=features/junkmail -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Search Query
I'm trying to build a search query that will allow users to search (via a textbox) different tables. For example, I have a table name contacts with columns ContactID, FirstName, LastName, and Active. I want to be able to search for John Smith or Smith where Active=yes (as opposed to Active=no which would indicate the contact is no longer active). I would then like to have the result(s) to have a link to their respective ContactID. I don't think this is that difficult, but I'm having difficulty applying the SELECT statement with the text box. Any help would be greatly appreciated. Steve Fitzgerald -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]