Re: [PHP] search array
On Thu, Apr 11, 2013 at 1:37 PM, Russell Brackett rbrack...@capitolabs.com wrote: I need help with this code to echo all items in the general database and not just the fields I'm searching for. ?php // filter function function cleanInput($input) { $search = array('OEM Name, Category, OEM Name'); $output = str_replace($search, '', $input); return $output; } //define layout name $layoutName = 'SYSTEMS CONFIGURATOR'; //block for pagination if(isset($_GET['page']) !empty($_GET['page'])){ $page = $_GET['page']; } else{ $page = 1; } $max = 20; $skip = ($page - 1) * $max; // grab their search query and clean it if($_POST){ $searchQuery= $_POST['q']; $_SESSION['searchQuery'] = $searchQuery; } else{ if(!isset($_SESSION['searchQuery'])){ header('location: index.php'); } } //$searchQuery= amat; // sanitize $cleanInput = cleanInput($_SESSION['searchQuery']); // Add 1st request for serial number $findSerial = $fm-newFindRequest($layoutName); $findSerial-addFindCriterion('OEM Name', $cleanInput); // Add 2nd request for category $findDesc = $fm-newFindRequest($layoutName); $findDesc-addFindCriterion('Category', $cleanInput); // search the description field //$find-addFindCriterion('description', $cleanInput); // sort the results //do a compound find with above two search conditions $compoundFind = $fm-newCompoundFindCommand($layoutName); $compoundFind-add(1, $findSerial); $compoundFind-add(2, $findDesc); $compoundFind-addSortRule('Serial #', 1, FILEMAKER_SORT_ASCEND); // set skip and max values $compoundFind-setRange($skip, $max); // run the search $result = $compoundFind-execute(); $records = $result-getRecords(); //get found count and get total page number $foundCount = $result-getFoundSetCount(); $totalPage = ceil($foundCount / $max); // create the smarty object $smarty = new Smarty(); $smarty-force_compile = true; $smarty-debugging = false; $smarty-caching = false; //$smarty-cache_lifetime = 120; ? Russell Brackett Web Developer Capitol Area Technology 3500 Comsouth Suite 500 Austin, Texas, 78744 rbrack...@capitolabs.commailto:c.h...@capitolabs.com Office 512-610-3246 Cell 979-412-3018 Capitol Area Technology: Integrity-Courtesy-Customer Satisfaction Where do these methods come from? // Add 1st request for serial number $findSerial = $fm-newFindRequest($layoutName); $findSerial-addFindCriterion('OEM Name', $cleanInput); // Add 2nd request for category $findDesc = $fm-newFindRequest($layoutName); $findDesc-addFindCriterion('Category', $cleanInput); // search the description field //$find-addFindCriterion('description', $cleanInput); // sort the results //do a compound find with above two search conditions $compoundFind = $fm-newCompoundFindCommand($layoutName); $compoundFind-add(1, $findSerial); $compoundFind-add(2, $findDesc); $compoundFind-addSortRule('Serial #', 1, FILEMAKER_SORT_ASCEND); // set skip and max values $compoundFind-setRange($skip, $max); // run the search $result = $compoundFind-execute(); I'm not familiar with them as one of the usual PHP database extensions. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: Re: [PHP] Search for string followed by whitespace
On Fri, Sep 23, 2011 at 13:21, Tim Streater t...@clothears.org.uk wrote: Dan, Thanks for the suggestion but I need to know where the string occurs as I want to then do some excision/incision. Consider preg_replace() with that same pattern. Or, at the most involved, preg_replace_callback(). -- /Daniel P. Brown Network Infrastructure Manager http://www.php.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Search for string followed by whitespace
On Sun, Sep 18, 2011 at 15:12, Tim Streater t...@clothears.org.uk wrote: At the moment, I'm doing this: $start = stripos ($body, a , $loc); You'll note the space after the 'a'. But I really need to search in $body for 'a' followed by any whitespace char, at least one, starting at the $loc'th character, and returning the location of the string in $start. I had a look at the PCRE and POSIX regexp functions to no avail. Is there a slick way of doing this with one function call or should I just search for 'a' and brute-force check that the next char is ' ' or '\t' or '\n'? Thanks, Try something along this line: ?php preg_match_all('/a\b/Ui',$text,$matches); ? Replace $text with the text through which you want to look, and your results will be an array in $matches. The \b switch in the regexp will match any word/letter border, which includes whitespaces, tabs, newlines, periods, et cetera. Essentially, anything that you'll want to match inside HTML tags, be they valid or otherwise. The U modifier makes the search Ungreedy, while the i modifier makes it case-iNsEnSiTiVe. -- /Daniel P. Brown Network Infrastructure Manager http://www.php.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] search is not case insensitive
At 10:23 PM -0700 11/1/10, Tommy Pham wrote: -Original Message- From: tedd [mailto:tedd.sperl...@gmail.com] Sent: Sunday, October 31, 2010 9:00 AM To: g...@holisticgp.com.au; php-general@lists.php.net Subject: Re: [PHP] search is not case insensitive At 3:47 PM +1100 10/31/10, Dr Michael Daly wrote: Hi Using a php search form produces a nil return on any information that is capitalised within a mysql database; retrieval is fine for non-capitalised data. Could someone tweak this please? The relevant code I think is as follows: // Description is a BLOB in MySQL... we need to UPPER the blob //values to make the search case-insensitive. $query = SELECT C.*, A.surname, A.name, A.surname_prefix, A.id AS user FROM pbcs_user A, pbcs_join_table_user_app B, pbcs_appointment C . WHERE A.id = B.user_id AND B.appointment_id = C.id. AND LOWER(C.description) LIKE '%.strtolower($search_for).%' AND C.start_time $start_time AND C.start_time $end_time ORDER BY C.start_time; $result = pbcs_db_query($query); Thanks Michael Melb, Aust. Why are you using a BLOB? You are just storing text data, right? If so, then a VARCHAR will work. Additionally, using a BLOB changes things somewhat in that all data are stored as binary strings and as such makes all comparisons case-sensitive. Too many double negatives for me. Cheers, tedd -- --- http://sperling.com/ IIRC, the VARCHAR (for MySQL) has a limit of 255 chars. You may have to use one of the *TEXT variants if you need to store a lot of text. Regards, Tommy Tommy: If you are using a version of MySQL that is older than v 5.0.3, then you are right -- but after that version VARCHAR can hold up to 65,535 characters. How much does the OP need? If that is not enough room, then why not use LONGTEXT (4G)? The differences are how the data is stored. In BLOBS the data is stored in binary strings with no char set and comparisons are based on numeric values of bytes. Whereas, TEXT data are treated as character strings which have a char set and can be sorted and compared based upon collation of the char set. Cheers, tedd -- --- http://sperling.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] search is not case insensitive
-Original Message- From: tedd [mailto:tedd.sperl...@gmail.com] Sent: Tuesday, November 02, 2010 8:09 AM To: Tommy Pham; g...@holisticgp.com.au; php-general@lists.php.net Subject: RE: [PHP] search is not case insensitive At 10:23 PM -0700 11/1/10, Tommy Pham wrote: -Original Message- From: tedd [mailto:tedd.sperl...@gmail.com] Sent: Sunday, October 31, 2010 9:00 AM To: g...@holisticgp.com.au; php-general@lists.php.net Subject: Re: [PHP] search is not case insensitive At 3:47 PM +1100 10/31/10, Dr Michael Daly wrote: Hi Using a php search form produces a nil return on any information that is capitalised within a mysql database; retrieval is fine for non-capitalised data. Could someone tweak this please? The relevant code I think is as follows: // Description is a BLOB in MySQL... we need to UPPER the blob //values to make the search case-insensitive. $query = SELECT C.*, A.surname, A.name, A.surname_prefix, A.id AS user FROM pbcs_user A, pbcs_join_table_user_app B, pbcs_appointment C . WHERE A.id = B.user_id AND B.appointment_id = C.id . AND LOWER(C.description) LIKE '%.strtolower($search_for).%' AND C.start_time $start_time AND C.start_time $end_time ORDER BY C.start_time; $result = pbcs_db_query($query); Thanks Michael Melb, Aust. Why are you using a BLOB? You are just storing text data, right? If so, then a VARCHAR will work. Additionally, using a BLOB changes things somewhat in that all data are stored as binary strings and as such makes all comparisons case- sensitive. Too many double negatives for me. Cheers, tedd -- --- http://sperling.com/ IIRC, the VARCHAR (for MySQL) has a limit of 255 chars. You may have to use one of the *TEXT variants if you need to store a lot of text. Regards, Tommy Tommy: If you are using a version of MySQL that is older than v 5.0.3, then you are right -- but after that version VARCHAR can hold up to 65,535 characters. Tedd, That tells you that I haven't been keeping track of version changes for MySQL. I remember that when 5 was still an RC. How much does the OP need? If that is not enough room, then why not use LONGTEXT (4G)? The differences are how the data is stored. In BLOBS the data is stored in binary strings with no char set and comparisons are based on numeric values of bytes. Whereas, TEXT data are treated as character strings which have a char set and can be sorted and compared based upon collation of the char set. Cheers, tedd -- --- http://sperling.com/ I totally agree on VARCHAR/TEXT over BLOBs as you can use the index (with/without FULLTEXT) more efficiently for faster query results. Regards, Tommy -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] search is not case insensitive
-Original Message- From: a...@ashleysheridan.co.uk [mailto:a...@ashleysheridan.co.uk] Sent: Sunday, October 31, 2010 2:10 AM To: Dr Michael Daly; php-general@lists.php.net Subject: Re: [PHP] search is not case insensitive This isn't a php question but a mysql one. Take out the lower() part of the sql statement, as like is case insensitive by default. Thanks, Ash http://www.ashleysheridan.co.uk - Reply message - From: Dr Michael Daly g...@holisticgp.com.au Date: Sun, Oct 31, 2010 04:47 Subject: [PHP] search is not case insensitive To: php-general@lists.php.net Hi Using a php search form produces a nil return on any information that is capitalised within a mysql database; retrieval is fine for non-capitalised data. Could someone tweak this please? The relevant code I think is as follows: // Description is a BLOB in MySQL... we need to UPPER the blob //values to make the search case-insensitive. $query = SELECT C.*, A.surname, A.name, A.surname_prefix, A.id AS user FROM pbcs_user A, pbcs_join_table_user_app B, pbcs_appointment C . WHERE A.id = B.user_id AND B.appointment_id = C.id . AND LOWER(C.description) LIKE '%.strtolower($search_for).%' AND C.start_time $start_time AND C.start_time $end_time ORDER BY C.start_time; $result = pbcs_db_query($query); Thanks Michael Melb, Aust. You could also remove the strtolower(). Just to be sure that field C.description is set with case-insensitive collation, you could use phpMyAdmin to look at the table structure or run SQL 'show create table pbcs_appointment;' on your MySQL tool. The description column should have *_ci (for case-insensitive whereas *_cs is case-sensitive). Regards, Tommy -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] search is not case insensitive
-Original Message- From: tedd [mailto:tedd.sperl...@gmail.com] Sent: Sunday, October 31, 2010 9:00 AM To: g...@holisticgp.com.au; php-general@lists.php.net Subject: Re: [PHP] search is not case insensitive At 3:47 PM +1100 10/31/10, Dr Michael Daly wrote: Hi Using a php search form produces a nil return on any information that is capitalised within a mysql database; retrieval is fine for non-capitalised data. Could someone tweak this please? The relevant code I think is as follows: // Description is a BLOB in MySQL... we need to UPPER the blob //values to make the search case-insensitive. $query = SELECT C.*, A.surname, A.name, A.surname_prefix, A.id AS user FROM pbcs_user A, pbcs_join_table_user_app B, pbcs_appointment C . WHERE A.id = B.user_id AND B.appointment_id = C.id . AND LOWER(C.description) LIKE '%.strtolower($search_for).%' AND C.start_time $start_time AND C.start_time $end_time ORDER BY C.start_time; $result = pbcs_db_query($query); Thanks Michael Melb, Aust. Why are you using a BLOB? You are just storing text data, right? If so, then a VARCHAR will work. Additionally, using a BLOB changes things somewhat in that all data are stored as binary strings and as such makes all comparisons case-sensitive. Too many double negatives for me. Cheers, tedd -- --- http://sperling.com/ IIRC, the VARCHAR (for MySQL) has a limit of 255 chars. You may have to use one of the *TEXT variants if you need to store a lot of text. Regards, Tommy -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] search is not case insensitive
This isn't a php question but a mysql one. Take out the lower() part of the sql statement, as like is case insensitive by default. Thanks, Ash http://www.ashleysheridan.co.uk - Reply message - From: Dr Michael Daly g...@holisticgp.com.au Date: Sun, Oct 31, 2010 04:47 Subject: [PHP] search is not case insensitive To: php-general@lists.php.net Hi Using a php search form produces a nil return on any information that is capitalised within a mysql database; retrieval is fine for non-capitalised data. Could someone tweak this please? The relevant code I think is as follows: // Description is a BLOB in MySQL... we need to UPPER the blob //values to make the search case-insensitive. $query = SELECT C.*, A.surname, A.name, A.surname_prefix, A.id AS user FROM pbcs_user A, pbcs_join_table_user_app B, pbcs_appointment C. WHERE A.id = B.user_id AND B.appointment_id = C.id . AND LOWER(C.description) LIKE '%.strtolower($search_for).%' AND C.start_time $start_time AND C.start_time $end_time ORDER BY C.start_time; $result = pbcs_db_query($query); Thanks Michael Melb, Aust. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] search is not case insensitive
thanks for this Ash...I didn't really understand but I do now! unfortunately the fix didn't work, possibly bec the mysql data is in binary format (default then becomes: case sensitive). I got a 'syntax error' result I'll find a mysql forum Michael This isn't a php question but a mysql one. Take out the lower() part of the sql statement, as like is case insensitive by default. Thanks, Ash http://www.ashleysheridan.co.uk - Reply message - From: Dr Michael Daly g...@holisticgp.com.au Date: Sun, Oct 31, 2010 04:47 Subject: [PHP] search is not case insensitive To: php-general@lists.php.net Hi Using a php search form produces a nil return on any information that is capitalised within a mysql database; retrieval is fine for non-capitalised data. Could someone tweak this please? The relevant code I think is as follows: // Description is a BLOB in MySQL... we need to UPPER the blob //values to make the search case-insensitive. $query = SELECT C.*, A.surname, A.name, A.surname_prefix, A.id AS user FROM pbcs_user A, pbcs_join_table_user_app B, pbcs_appointment C. WHERE A.id = B.user_id AND B.appointment_id = C.id . AND LOWER(C.description) LIKE '%.strtolower($search_for).%' AND C.start_time $start_time AND C.start_time $end_time ORDER BY C.start_time; $result = pbcs_db_query($query); Thanks Michael Melb, Aust. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Dr Michael Daly MB, BS GradDip(Integrative Medicine), GradCert(Evidence Based Practice), M Bus(Information Innovation), GradDip(Document Management) 03 9521 0352 0413 879 029 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] search is not case insensitive
At 3:47 PM +1100 10/31/10, Dr Michael Daly wrote: Hi Using a php search form produces a nil return on any information that is capitalised within a mysql database; retrieval is fine for non-capitalised data. Could someone tweak this please? The relevant code I think is as follows: // Description is a BLOB in MySQL... we need to UPPER the blob //values to make the search case-insensitive. $query = SELECT C.*, A.surname, A.name, A.surname_prefix, A.id AS user FROM pbcs_user A, pbcs_join_table_user_app B, pbcs_appointment C. WHERE A.id = B.user_id AND B.appointment_id = C.id . AND LOWER(C.description) LIKE '%.strtolower($search_for).%' AND C.start_time $start_time AND C.start_time $end_time ORDER BY C.start_time; $result = pbcs_db_query($query); Thanks Michael Melb, Aust. Why are you using a BLOB? You are just storing text data, right? If so, then a VARCHAR will work. Additionally, using a BLOB changes things somewhat in that all data are stored as binary strings and as such makes all comparisons case-sensitive. Too many double negatives for me. Cheers, tedd -- --- http://sperling.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Search Query on two tables not working
On Tue, Jul 21, 2009 at 12:26 PM, Miller, Teriontmil...@springfi.gannett.com wrote: Why isn't this working for searching? Check your concatenation in the query. You need some white space padding your SQL segments, otherwise the text all starts to run together. (I had to reformat it. For some reason, most of the code snippets you post end up all run together on a single line, at least in Gmail.) ?php // Run query on submitted values. Store results in $SESSION and redirect to restaurants.php $sql = SELECT name, address, inDate, inType, notes, critical, cviolations, noncritical FROM restaurants, inspections WHERE restaurants.name '' AND restaurant.ID = inspection.ID; if ($searchName){ // ADDED SPACE HERE $sql .= AND restaurants.name LIKE '%. mysql_real_escape_string($name) .%' ; if(count($name2) == 1){ // ADDED SPACE HERE $sql .= AND restaurants.name LIKE '%. mysql_real_escape_string($name2[1]) .%' ; }else{ foreach($name2 as $namePart){ // ADDED SPACE HERE $sql .= AND restaurants.name LIKE '%. mysql_real_escape_string($namePart) .%' ; } } } if ($searchAddress) { // ADDED SPACE HERE $sql .= AND restaurants.address LIKE '%. mysql_real_escape_string($address) .%' ; } // ADDED SPACE HERE $sql .= ORDER BY restaurants.name;; $result = mysql_query($sql); Andrew -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Search Query on two tables not working
Why isn't this working for searching? // Run query on submitted values. Store results in $SESSION and redirect to restaurants.php$sql = SELECT name, address, inDate, inType, notes, critical, cviolations, noncritical FROM restaurants, inspections WHERE restaurants.name '' AND restaurant.ID = inspection.ID;if ($searchName){ $sql .= AND restaurants.name LIKE '%. mysql_real_escape_string($name) .%' ;if(count($name2) == 1){ $sql .= AND restaurants.name LIKE '%. mysql_real_escape_string($name2[1]) .%' ;}else{ foreach($name2 as $namePart){$sql .= AND restaurants.name LIKE '%. mysql_real_escape_string($namePart) .%' ; }}}if ($searchAddress) {$sql .= AND restaurants.address LIKE '%. mysql_real_escape_string($address) .%' ; } $sql .= ORDER BY restaurants.name;; $result = mysql_query($sql); I'm not sure about MySQL, but in Informix my queries will crash when trying to just append the ORDER BY clause by itself. $sql .= ORDER BY restaurants.name;; Also, you have a semi colon before and after the ending quote. TRY $sql .= AND 1 = 1 ORDER BY restaurants.name;
Re: [PHP] Search Query on two tables not working
On 7/21/09 11:47 AM, Dan Shirah mrsqua...@gmail.com wrote: Why isn't this working for searching? // Run query on submitted values. Store results in $SESSION and redirect to restaurants.php$sql = SELECT name, address, inDate, inType, notes, critical, cviolations, noncritical FROM restaurants, inspections WHERE restaurants.name http://restaurants.name/http://restaurants.name/ '' AND restaurant.ID = inspection.ID;if ($searchName){ $sql .= AND restaurants.name http://restaurants.name/http://restaurants.name/ LIKE '%. mysql_real_escape_string($name) .%' ;if(count($name2) == 1){ $sql .= AND restaurants.name http://restaurants.name/http://restaurants.name/ LIKE '%. mysql_real_escape_string($name2[1]) .%' ;}else{ foreach($name2 as $namePart){$sql .= AND restaurants.name http://restaurants.name/http://restaurants.name/ LIKE '%. mysql_real_escape_string($namePart) .%' ;}}}if ($searchAddress) {$sql .= AND restaurants.address LIKE '%. mysql_real_escape_string($address) .%' ;} $sql .= ORDER BY restaurants.name http://restaurants.name/http://restaurants.name/ ;; $result = mysql_query($sql); I'm not sure about MySQL, but in Informix my queries will crash when trying to just append the ORDER BY clause by itself. $sql .= ORDER BY restaurants.name http://restaurants.namehttp://restaurants.name ;; Also, you have a semi colon before and after the ending quote. TRY $sql .= AND 1 = 1 ORDER BY restaurants.name http://restaurants.namehttp://restaurants.name ; Got the query to this point now: Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /var/www/vhosts/getpublished.news-leader.com/httpdocs/ResturantInspections/processRestaurantSearch.php on line 119 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Search Query on two tables not working
On 7/21/09 12:04 PM, Ashley Sheridan a...@ashleysheridan.co.uk wrote: On Tue, 2009-07-21 at 12:59 -0400, Miller, Terion wrote: On 7/21/09 11:47 AM, Dan Shirah mrsqua...@gmail.com wrote: Why isn't this working for searching? // Run query on submitted values. Store results in $SESSION and redirect to restaurants.php$sql = SELECT name, address, inDate, inType, notes, critical, cviolations, noncritical FROM restaurants, inspections WHERE restaurants.name http://restaurants.name/http://restaurants.name/http://restaurants.name/http://restaurants.name/ '' AND restaurant.ID = inspection.ID;if ($searchName){ $sql .= AND restaurants.name http://restaurants.name/http://restaurants.name/http://restaurants.name/http://restaurants.name/ LIKE '%. mysql_real_escape_string($name) .%' ;if(count($name2) == 1){$sql .= AND restaurants.name http://restaurants.name/http://restaurants.name/http://restaurants.name/http://restaurants.name/ LIKE '%. mysql_real_escape_string($name2[1]) .%' ;}else{ foreach($name2 as $namePart){$sql .= AND restaurants.name http://restaurants.name/http://restaurants.name/http://restaurants.name/http://restaurants.name/ LIKE '%. mysql_real_escape_string($namePart) .%' ;}}} if ($searchAddress) {$sql .= AND restaurants.address LIKE '%. mysql_real_escape_string($address) .%' ;} $sql .= ORDER BY restaurants.name http://restaurants.name/http://restaurants.name/http://restaurants.name/http://restaurants.name/ ;;$result = mysql_query($sql); I'm not sure about MySQL, but in Informix my queries will crash when trying to just append the ORDER BY clause by itself. $sql .= ORDER BY restaurants.name http://restaurants.namehttp://restaurants.namehttp://restaurants.namehttp://restaurants.name ;; Also, you have a semi colon before and after the ending quote. TRY $sql .= AND 1 = 1 ORDER BY restaurants.name http://restaurants.namehttp://restaurants.namehttp://restaurants.namehttp://restaurants.name ; Got the query to this point now: Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /var/www/vhosts/getpublished.news-leader.com/httpdocs/ResturantInspections/processRestaurantSearch.php on line 119 That means your query is invalid. Try printing the query out and posting it here so that we can see it. Thanks Ash www.ashleysheridan.co.uk I Got this error when I echo'd the sql $results ; 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 'restaurants.name LIKE '%A%' AND restaurants.name LIKE '%A%' ORDER BY restaurants' at line 1 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Search Query on two tables not working
Turned off the redirects on the whole script and tried to the the query to echo and these are the errors I got: Notice: Undefined offset: 1 in /var/www/vhosts/getpublished.news-leader.com/httpdocs/ResturantInspections/processRestaurantSearch.php on line 89 Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /var/www/vhosts/getpublished.news-leader.com/httpdocs/ResturantInspections/processRestaurantSearch.php on line 119 On 7/21/09 11:32 AM, Kevin Smith ke...@netsmith.ltd.uk wrote: Can you supply the actual generated SQL, I can potentially see a problem, but need to see the final SQL statement. Miller, Terion wrote: Why isn't this working for searching? // Run query on submitted values. Store results in $SESSION and redirect to restaurants.php$sql = SELECT name, address, inDate, inType, notes, critical, cviolations, noncritical FROM restaurants, inspections WHERE restaurants.name '' AND restaurant.ID = inspection.ID;if ($searchName){ $sql .= AND restaurants.name LIKE '%. mysql_real_escape_string($name) .%' ;if(count($name2) == 1){ $sql .= AND restaurants.name LIKE '%. mysql_real_escape_string($name2[1]) .%' ;}else{ foreach($name2 as $namePart){$sql .= AND restaurants.name LIKE '%. mysql_real_escape_string($namePart) .%' ;}}} if ($searchAddress) {$sql .= AND restaurants.address LIKE '%. mysql_real_escape_string($address) .%' ;} $sql .= ORDER BY restaurants.name;;$result = mysql_query($sql); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Search Query on two tables not working
On Tue, Jul 21, 2009 at 12:41 PM, Miller, Terion tmil...@springfi.gannett.com wrote: Turned off the redirects on the whole script and tried to the the query to echo and these are the errors I got: Notice: Undefined offset: 1 in /var/www/vhosts/ getpublished.news-leader.com/httpdocs/ResturantInspections/processRestaurantSearch.phpon line 89 Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /var/www/vhosts/ getpublished.news-leader.com/httpdocs/ResturantInspections/processRestaurantSearch.phpon line 119 On 7/21/09 11:32 AM, Kevin Smith ke...@netsmith.ltd.uk wrote: Can you supply the actual generated SQL, I can potentially see a problem, but need to see the final SQL statement. print_r($sql);
Re: [PHP] Search Query on two tables not working
Here it is...I see where it's doing the restaurant.name LIKE statement 2x which is prob messing it up right...but in the code why is it doing that twice.. SELECT name, address, inDate, inType, notes, critical, cviolations, noncritical FROM restaurants, inspections WHERE restaurants.name '' AND restaurant.ID = inspection.IDAND restaurants.name LIKE '%A%' AND restaurants.name LIKE '%A%' ORDER BY restaurants.name; On 7/21/09 12:11 PM, Dan Shirah mrsqua...@gmail.com wrote: print_r($sql); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Search Query on two tables not working
On Tue, 2009-07-21 at 10:07 -0700, Miller, Terion wrote: On 7/21/09 12:04 PM, Ashley Sheridan a...@ashleysheridan.co.uk wrote: On Tue, 2009-07-21 at 12:59 -0400, Miller, Terion wrote: On 7/21/09 11:47 AM, Dan Shirah mrsqua...@gmail.com wrote: Why isn't this working for searching? // Run query on submitted values. Store results in $SESSION and redirect to restaurants.php$sql = SELECT name, address, inDate, inType, notes, critical, cviolations, noncritical FROM restaurants, inspections WHERE restaurants.name http://restaurants.name/http://restaurants.name/http://restaurants.name/http://restaurants.name/ '' AND restaurant.ID = inspection.ID;if ($searchName){ $sql .= AND restaurants.name http://restaurants.name/http://restaurants.name/http://restaurants.name/http://restaurants.name/ LIKE '%. mysql_real_escape_string($name) .%' ;if(count($name2) == 1){$sql .= AND restaurants.name http://restaurants.name/http://restaurants.name/http://restaurants.name/http://restaurants.name/ LIKE '%. mysql_real_escape_string($name2[1]) .%' ;}else{ foreach($name2 as $namePart){$sql .= AND restaurants.name http://restaurants.name/http://restaurants.name/http://restaurants.name/http://restaurants.name/ LIKE '%. mysql_real_escape_string($namePart) .%' ;}}} if ($searchAddress) {$sql .= AND restaurants.address LIKE '%. mysql_real_escape_string($address) .%' ;} $sql .= ORDER BY restaurants.name http://restaurants.name/http://restaurants.name/http://restaurants.name/http://restaurants.name/ ;;$result = mysql_query($sql); I'm not sure about MySQL, but in Informix my queries will crash when trying to just append the ORDER BY clause by itself. $sql .= ORDER BY restaurants.name http://restaurants.namehttp://restaurants.namehttp://restaurants.namehttp://restaurants.name ;; Also, you have a semi colon before and after the ending quote. TRY $sql .= AND 1 = 1 ORDER BY restaurants.name http://restaurants.namehttp://restaurants.namehttp://restaurants.namehttp://restaurants.name ; Got the query to this point now: Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /var/www/vhosts/getpublished.news-leader.com/httpdocs/ResturantInspections/processRestaurantSearch.php on line 119 That means your query is invalid. Try printing the query out and posting it here so that we can see it. Thanks Ash www.ashleysheridan.co.uk I Got this error when I echo'd the sql $results ; 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 'restaurants.name LIKE '%A%' AND restaurants.name LIKE '%A%' ORDER BY restaurants' at line 1 Yes, but that's not your query. The problem is with your query. If you echo the query, we can see where it might be falling over. Thanks Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Search Query on two tables not working
On Tue, Jul 21, 2009 at 1:20 PM, Miller, Teriontmil...@springfi.gannett.com wrote: Here it is...I see where it's doing the restaurant.name LIKE statement 2x which is prob messing it up right...but in the code why is it doing that twice.. SELECT name, address, inDate, inType, notes, critical, cviolations, noncritical FROM restaurants, inspections WHERE restaurants.name '' AND restaurant.ID = inspection.IDAND restaurants.name LIKE '%A%' AND restaurants.name LIKE '%A%' ORDER BY restaurants.name; It's not the multiple LIKE statements. It is the concatenation, like I said the last time. There is no white space between inspection.ID and AND. You may indeed have problems with some of those repeated conditions on restaurants.name, but if so they will be performance issues resulting from table scans, and not the errors you are reporting. Andrew -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Search Query on two tables not working
On Tue, 2009-07-21 at 12:59 -0400, Miller, Terion wrote: On 7/21/09 11:47 AM, Dan Shirah mrsqua...@gmail.com wrote: Why isn't this working for searching? // Run query on submitted values. Store results in $SESSION and redirect to restaurants.php$sql = SELECT name, address, inDate, inType, notes, critical, cviolations, noncritical FROM restaurants, inspections WHERE restaurants.name http://restaurants.name/http://restaurants.name/ '' AND restaurant.ID = inspection.ID;if ($searchName){ $sql .= AND restaurants.name http://restaurants.name/http://restaurants.name/ LIKE '%. mysql_real_escape_string($name) .%' ;if(count($name2) == 1) {$sql .= AND restaurants.name http://restaurants.name/http://restaurants.name/ LIKE '%. mysql_real_escape_string($name2[1]) .%' ;}else{ foreach($name2 as $namePart){$sql .= AND restaurants.name http://restaurants.name/http://restaurants.name/ LIKE '%. mysql_real_escape_string($namePart) .%' ;}}}if ($searchAddress) {$sql .= AND restaurants.address LIKE '%. mysql_real_escape_string($address) .%' ;} $sql .= ORDER BY restaurants.name http://restaurants.name/http://restaurants.name/ ;; $result = mysql_query($sql); I'm not sure about MySQL, but in Informix my queries will crash when trying to just append the ORDER BY clause by itself. $sql .= ORDER BY restaurants.name http://restaurants.namehttp://restaurants.name ;; Also, you have a semi colon before and after the ending quote. TRY $sql .= AND 1 = 1 ORDER BY restaurants.name http://restaurants.namehttp://restaurants.name ; Got the query to this point now: Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /var/www/vhosts/getpublished.news-leader.com/httpdocs/ResturantInspections/processRestaurantSearch.php on line 119 That means your query is invalid. Try printing the query out and posting it here so that we can see it. Thanks Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Search Query on two tables not working
On Tue, 2009-07-21 at 13:24 -0400, Andrew Ballard wrote: On Tue, Jul 21, 2009 at 1:20 PM, Miller, Teriontmil...@springfi.gannett.com wrote: Here it is...I see where it's doing the restaurant.name LIKE statement 2x which is prob messing it up right...but in the code why is it doing that twice.. SELECT name, address, inDate, inType, notes, critical, cviolations, noncritical FROM restaurants, inspections WHERE restaurants.name '' AND restaurant.ID = inspection.IDAND restaurants.name LIKE '%A%' AND restaurants.name LIKE '%A%' ORDER BY restaurants.name; It's not the multiple LIKE statements. It is the concatenation, like I said the last time. There is no white space between inspection.ID and AND. You may indeed have problems with some of those repeated conditions on restaurants.name, but if so they will be performance issues resulting from table scans, and not the errors you are reporting. Andrew It's always better putting in extra whitespace at both ends of each part of the query you are concatenating if you're unsure. Like Andrew said, MySQL will balk if you have none between keywords, but I've never heard it complaining about an extra space or two! Thanks Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Search Query on two tables not working (RESOLVED)
Yep, sure was the spacesOMG...will I ever get it... On 7/21/09 12:29 PM, Ashley Sheridan a...@ashleysheridan.co.uk wrote: On Tue, 2009-07-21 at 13:24 -0400, Andrew Ballard wrote: On Tue, Jul 21, 2009 at 1:20 PM, Miller, Teriontmil...@springfi.gannett.com wrote: Here it is...I see where it's doing the restaurant.name LIKE statement 2x which is prob messing it up right...but in the code why is it doing that twice.. SELECT name, address, inDate, inType, notes, critical, cviolations, noncritical FROM restaurants, inspections WHERE restaurants.name '' AND restaurant.ID = inspection.IDAND restaurants.name LIKE '%A%' AND restaurants.name LIKE '%A%' ORDER BY restaurants.name; It's not the multiple LIKE statements. It is the concatenation, like I said the last time. There is no white space between inspection.ID and AND. You may indeed have problems with some of those repeated conditions on restaurants.name, but if so they will be performance issues resulting from table scans, and not the errors you are reporting. Andrew It's always better putting in extra whitespace at both ends of each part of the query you are concatenating if you're unsure. Like Andrew said, MySQL will balk if you have none between keywords, but I've never heard it complaining about an extra space or two! Thanks Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Search/Replace in entire database?
Hi Chris, MySQL introduced full - text indexing and searching capabilities back in version 3.23.23. The implementation is straightforward and easy to use — define a FULLTEXT index and use MATCH / AGAINST in the query. Consider this example: CREATE TABLE SOCIAL_EVENT ( EVENT_ID INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, USER_ID INTEGER UNSIGNED NOT NULL, HEADLINE TEXT NOT NULL, EVENT_TEXT TEXT NOT NULL, EVENT_DATE TIMESTAMP NOT NULL, PRIMARY KEY (EVENT_ID), FOREIGN KEY (USER_ID) REFERENCES SOCIAL_USER(USER_ID), FULLTEXT INDEX (HEADLINE, EVENT_TEXT) ) ENGINE=MyISAM DEFAULT CHARACTER SET latin1 COLLATE latin1_general_cs AUTO_INCREMENT=0; Thanks. Caner 2009/6/15 Chris Payne chris_pa...@danmangames.com Hi everyone, I am in the middle of creating an editor where you can search and replace on an individual column in a single table then I came across something I need to be able to do but not sure how. Is it posible (And if so please how :-) to search an entire database and all tables within a database and do a find/replace on keywords without having to specify each table/column within that table? The people I am working for have made some big changes and one of them is changing the names of one of their products, but this product name appears EVERYWHERE in many tables and in lots of different column names, and it would save so much time if I could do a single query that would just search EVERYTHING within the database. Thanks for any advice you can give me. Regards Chris Payne -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Search/Replace in entire database?
At 9:17 PM -0700 6/14/09, Chris Payne wrote: Hi everyone, I am in the middle of creating an editor where you can search and replace on an individual column in a single table then I came across something I need to be able to do but not sure how. Is it posible (And if so please how :-) to search an entire database and all tables within a database and do a find/replace on keywords without having to specify each table/column within that table? The people I am working for have made some big changes and one of them is changing the names of one of their products, but this product name appears EVERYWHERE in many tables and in lots of different column names, and it would save so much time if I could do a single query that would just search EVERYTHING within the database. Thanks for any advice you can give me. Regards Chris Payne Chris: The problem you cite is exactly why one should use relational databases. If the people you are working for had done that, then you would have only to edit one table. The process works like this -- you have a product table that has an unique id with other information about each product, such as its name. However, every table that references that product does so via the product's id and not the product's name. As such, each look-up for the product name requires first to know the product's id and then pull out the name associated with that id. In any event, a little more work at the start saves tons later. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Search functionality in website.
On Mon, Dec 29, 2008 at 10:47 AM, Tiji varghese tij...@yahoo.co.in wrote: Hi all,I would like to set up search functionality on my website. I'm using PHP and Mysql. Most of the pages contain static text in the html and is not database driven. I need some idea on how should I go about it without moving everything to database driven functionality. Please help.Thanks in advance! Add more friends to your messenger and enjoy! Go to http://messenger.yahoo.com/invite/ ht-dig (or digg)
Re: [PHP] Search functionality in website.
Or even a google search widget... Miles Thompson wrote: On Mon, Dec 29, 2008 at 10:47 AM, Tiji varghese tij...@yahoo.co.in wrote: ht-dig (or digg) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Search functionality in website.
Hi all,I would like to set up search functionality on my website. I'm using PHP and Mysql. Most of the pages contain static text in the html and is not database driven. I need some idea on how should I go about it without moving everything to database driven functionality. You could look into using Zend_Search_Lucene (part of the Zend framework). Never used it myself, but from what I've read about it, it looks quite good (plus it's file based, ie. you don't need MySQL). There's also the Google search widget like I use on my personal website: http://www.phpguru.org -- Richard Heyes HTML5 Graphing for FF, Chrome, Opera and Safari: http://www.rgraph.org (Updated December 20th) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Search functionality in website.
At 8:17 PM +0530 12/29/08, Tiji varghese wrote: Hi all,I would like to set up search functionality on my website. I'm using PHP and Mysql. Most of the pages contain static text in the html and is not database driven. I need some idea on how should I go about it without moving everything to database driven functionality. Please help.Thanks in advance! Try: http://sperling.com/examples/search/ Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] search for person by comparing his data with data in mysql
c...@l-i-e.com schreef: select first_name like '%$first_name%' + 3 * last_name like '%$last_name%' + 7 * email = '$email' as score, that works?? I guess the expressions (e.g. email = '$email') evaluate to bools and are auto-cast to ints. Im guess there needs to be some parenthesis in there somewhere, no? anyway nice snippet :-) first_name, last_name, email, person_id from person . . . order by score desc limit 10 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] search for person by comparing his data with data in mysql
On Sat, Dec 20, 2008 at 7:01 AM, Jochem Maas joc...@iamjochem.com wrote: c...@l-i-e.com schreef: select first_name like '%$first_name%' + 3 * last_name like '%$last_name%' + 7 * email = '$email' as score, that works?? I guess the expressions (e.g. email = '$email') evaluate to bools and are auto-cast to ints. Im guess there needs to be some parenthesis in there somewhere, no? anyway nice snippet :-) If it works, it must be a MySQL feature. Andrew -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] search for person by comparing his data with data in mysql
select first_name like '%$first_name%' + 3 * last_name like '%$last_name%' + 7 * email = '$email' as score, first_name, last_name, email, person_id from person . . . order by score desc limit 10 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Search functionality
Its pretty straight forward, you create a query that extracts the name and id of the records with a relevant where clause created on the fly. When outputing the data, each record gets created as a link that then loads another page/div with the total dataset for that record. The question for you is how you want the interface for the search to work. You can provide a dropdown with some choices (date, zip, etc) and a text input / date input picker to allow the user to enter the data. This then gets submitted and runs the query Correct, right now each record is displayed on the screen as a link. When the link is clicked a query runs to pull all of the related data and displays it as a subset of items under the main link. The problem is, since I am not pulling all of the detail when I run the initial query, what would be the best way to find the search results when they will most liely be contained in the data I did not initially pull.
Re: [PHP] Search functionality
On Wed, Sep 24, 2008 at 4:47 PM, Dan Shirah [EMAIL PROTECTED] wrote: Its pretty straight forward, you create a query that extracts the name and id of the records with a relevant where clause created on the fly. When outputing the data, each record gets created as a link that then loads another page/div with the total dataset for that record. The question for you is how you want the interface for the search to work. You can provide a dropdown with some choices (date, zip, etc) and a text input / date input picker to allow the user to enter the data. This then gets submitted and runs the query Correct, right now each record is displayed on the screen as a link. When the link is clicked a query runs to pull all of the related data and displays it as a subset of items under the main link. The problem is, since I am not pulling all of the detail when I run the initial query, what would be the best way to find the search results when they will most liely be contained in the data I did not initially pull. Pass the search criteria previously entered thru session or hidden fields or in the url along with the id to further refine the search -- Bastien Cat, the other other white meat
Re: [PHP] Search functionality
On Mon, Sep 22, 2008 at 4:07 PM, Dan Shirah [EMAIL PROTECTED] wrote: Hello all, I'm looking for suggestions on how to create a search function within my application. First I'll give you an overview. At the top of my page I have a form that contains name and date fields. When a user puts in some data and selects Search a simple column of results will be displayed on the left side of the screen. Example: User searchs for a date of 09/22/08 and a name of Customers. In the left column a list of all customers for that day will be generated. There is A LOT of detail associated with these customer results therefore all data such as name, address, zip code, order number etc is not pulled from the database upon initial search. Instead, if a user clicks a customer name a seperate query will run and retrieve all of the pertinent data and provide a bulleted list under the customer name. What my vendor wants me to do is provide a way for someone to search through all the customers including the details that I do not initially display to allow them to find specific data. Such as finiding a record with a specific zip code. They then want to be able to click next to go to each consecutive record with that zip code. Any ideas on how to do this since all that data is not initially pulled in? Its pretty straight forward, you create a query that extracts the name and id of the records with a relevant where clause created on the fly. When outputing the data, each record gets created as a link that then loads another page/div with the total dataset for that record. The question for you is how you want the interface for the search to work. You can provide a dropdown with some choices (date, zip, etc) and a text input / date input picker to allow the user to enter the data. This then gets submitted and runs the query ?php //ignoring all the little details like data validation which you need to put in $query_type = $_POST['query_type']; // zip, date, (text value of the dropdown) $param = $_POST['param']; $sql = select cus_id, cus_name from customers where 1 ; if(!empty($query_type)){ //use this to point to the correct field in the table switch strtolower($query_type){ case date: $field = join_date ; $param = (strtotime($param) !== false ) ? ' . date(Y-m-d, strtotime($param)) . ' : date(Y-m-d) ; //ternary check on date if strtotime doesn't fail break; case zip: $field = zip ; $param = (int)$param; //force to int for US 5 digit zip, could also use regex if you know what country you are operating in break; //add more case statements based on the element you want to allow } if (!empty($param)){ $sql .= and $field = $param ; } //skipping the mysql connection stuff $result = mysql_query($sql); if ( mysql_errno != 0 ) { //query went wrong so handle it die(Bad query!); } if (mysql_num_rows($result) 0 ) { while ($rows = mysql_fetch_array($result)){ echo a href='getDetail.php?id={$rows['cus_id']}'{$rows['cus_name']}/abr/; } }else{ echo No results; } ? or something like that -- Bastien Cat, the other other white meat
Re: [PHP] Search Suggestions
Dan Shirah schreef: Hello, I'm hoping to get a few good ideas on the best way to perform a search of PHP results. Currently I have a page that returns a list of collapsed customer data: Example + John Smith + Jane Doe + Robert Jones + Dale Bennett If the user clicks on a customer name it will expand the selection: Example - John Smith - 123 Anywhere Street - myCity - myState - myZipcode - myWebsite + Jane Doe + Robert Jones + Dale Bennett Now, what my client wants is a Search functionality that will allow him to type in myState and have the application automatically expand and focus on the first match. Then, be able to click Next and have it collapse the first result and expand the next result that contains the same state. Any ideas? I was thinking that maybe I would have to create a temp table so it could be searched against, but I'm not sure if that is the best idea. Also, in order to save processing time, the way I made the above expanding/collapsing list is I don't not pull in the customer details intially but instead run a query and get the details when the name is clicked for expansion. This is because there could be potentially 1,000's of result and getting all of the names and all of the details at page load would 1) take longer than a user is willing to wait 2) exceed the timeout 3) exceed the memory allocation I would think about caching data to streamline searching ... it would be very helpful if your address data was normalized when possible (e.g. states are related to users based on a database id rather than being loose bits of text) .. so that you can precalculate (e.g. via a cronjob) user ids that 'match' against certain strings) ... where you stick your cache is upto you. I would also cache the structured data for each user so that you can very quickly output (e.g. via JSON) the data for a given user/users to the browser. And then the fun part: build an ajaxy wotsit that paginates, sorts, searches and highlights the data ... and then couple it to server scripts that use the precalculated data to cough up matching users id (for searches) and userdata (for display). most of the hardwork will be in building the client side magic, the scripts that act as an interface on the precalculated data will be simple, and the precalculation routines shouldn't be to hairy (although you'll have to think careful about how to cover all your angles when it comes to the kind of data that can be search through) Thanks for any help/ideas. I'm interested to know if my brainfart made any sense to you :-) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Search Suggestions
At 9:31 AM -0400 8/26/08, Dan Shirah wrote: Any ideas? Dan: Yes, a few of them. 1. Use LIMIT in your MySQL query to get the number of records provided down to a manageable size. 2. Use pagination to keep the page size to a manageable size. Here's an example: http://php1.net/b/pagination-images/ Here's an example with code and it has an example of using LIMIT with offsets: http://webbytedd.com/bbb/paging/ 3. Then use a toggle for showing small/large amount of information. http://webbytedd.com/cc/toggle/ I often use this for showing clients lot's of data without having to show all of it at one time. Here's another example: http://sperling.com/quarters/ Note how The rules and How to win are shown. As to showing the user one item expanded and all the rest collapsed, I leave that to you, but my hint is redefining the css display rule (display: block) on the initial load of the page. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Search Suggestions
You could have (and I assume you already have) an id for each customer_name-DIV . This id should correspond to the customer id in your DB. You can then send out an AJAX request with the search term and have it return a list of the ids of the customer-DIV's to expand. A similar solution is to send back a list of names to expand, and then have Javascript go through the whole listing to find those names. Simcha Younger -Original Message- From: Dan Shirah [mailto:[EMAIL PROTECTED] Sent: Tuesday, August 26, 2008 3:31 PM To: PHP-General List Subject: [PHP] Search Suggestions Hello, I'm hoping to get a few good ideas on the best way to perform a search of PHP results. Currently I have a page that returns a list of collapsed customer data: Example + John Smith + Jane Doe + Robert Jones + Dale Bennett If the user clicks on a customer name it will expand the selection: Example - John Smith - 123 Anywhere Street - myCity - myState - myZipcode - myWebsite + Jane Doe + Robert Jones + Dale Bennett Now, what my client wants is a Search functionality that will allow him to type in myState and have the application automatically expand and focus on the first match. Then, be able to click Next and have it collapse the first result and expand the next result that contains the same state. Any ideas? I was thinking that maybe I would have to create a temp table so it could be searched against, but I'm not sure if that is the best idea. Also, in order to save processing time, the way I made the above expanding/collapsing list is I don't not pull in the customer details intially but instead run a query and get the details when the name is clicked for expansion. This is because there could be potentially 1,000's of result and getting all of the names and all of the details at page load would 1) take longer than a user is willing to wait 2) exceed the timeout 3) exceed the memory allocation Thanks for any help/ideas. Dan No virus found in this incoming message. Checked by AVG - http://www.avg.com Version: 8.0.138 / Virus Database: 270.6.7/1632 - Release Date: 25/08/2008 07:05 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Search thoughts
Mark Kelly wrote: Hi. On Saturday 19 July 2008, Richard Heyes wrote: Currently the site in question uses a very basic LIKE in MySQL, eg %blah%, but naturally this finds terms such as hjkblahbjkk - which is not desired. Or such matches should be ranked lower than something that matches the exact word blah. I did this with 2 queries, and no need for messing with points etc (unless you particularly want to). Start with LIKE 'word' query and pull the results into a results array. Then do the same query but with LIKE '%word%' and loop through append the results to the results array. Use something like if (!in_array($thisResult,$resultSet)) while appending to avoid duplicates. Well no. LIKE is slow and so is in_array(). Admittedly it's not a busy site, but still. How much traffic do you have and what's your hardware? Are your queries cached and subsequently repeated? Do you pre cache common queries? Cheers. -- Richard Heyes -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Search thoughts
At 10:47 AM +0100 7/19/08, Richard Heyes wrote: Hey, I was hoping to get some ideas on improving a sites search. Currently I have two - not a lot but I've been thinking about this for a few minutes. That'll leave a mark. :-) Currently the site in question uses a very basic LIKE in MySQL, eg %blah%, but naturally this finds terms such as hjkblahbjkk - which is not desired. Or such matches should be ranked lower than something that matches the exact word blah. My thoughts are using a points system, eg assigning 5 points for an exact word match, 1 for a partial match. And then ordering the search results by the total points assigned. I'm sure that would work, but just how many LIKE items do you want to show the user? For me, I would rather not show them anything if there is nothing on my site that matches their exact search criteria. The point being, from my perspective, users don't spend a lot of time reading results. They want answers quick and short. I would think that if you provided them with a long list of Did you mean this? results -- that might frustrate the user. If I did that, then I would also highlight each LIKE search word to show the user why the LIKE results were being presented to them. Either that or using external search code and not worrying so much. Considering all, using an external search would probably be better -- less time worrying about it and delivering good results to users queries is not as simple as it seems. However, if someone could come up with a better way, I am sure you could. But, the point is, would it make a difference? Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Search thoughts
I'm sure that would work, but just how many LIKE items do you want to show the user? For me, I would rather not show them anything if there is nothing on my site that matches their exact search criteria. Certainly an idea, but something like We also found... might be helpful in regard to typos. The point being, from my perspective, users don't spend a lot of time reading results. They want answers quick and short. I would think that if you provided them with a long list of Did you mean this? results -- that might frustrate the user. A good point. For example I rarely go further than the first page on Google (I never need to really, but whatever...). if someone could come up with a better way, I am sure you could. Thanks for the vote of confidence, but I've kept away from search as it doesn't overly interest me. In fact that's quite an over statement. It really bores the pants off me. But, the point is, would it make a difference? Well spending some time on it will improve it as it's just the basic LIKE at the moment, but point taken - I really don't want to spend a lot of time on it. -- Richard Heyes -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Search thoughts
Hi. Just noticed I replied direct rather than to the list last time, sorry about that. On Saturday 19 July 2008, Richard Heyes wrote: How much traffic do you have and what's your hardware? Are your queries cached and subsequently repeated? Do you pre cache common queries? I've done this kind of search twice, but both were for internal web apps so I can't link you to them. In both cases I return only items IDs and limit it to 10 results, with the subsequent queries being done only if the previous ones didn't return enough results to fill the page. Both of these speed it up a lot, obviously. One of them has a possible max of 6 different ways to examine the data tables, and still return a full results page in under half a second. Nothing is pre-cached, and I'm really not sure about the hardware, sorry, that's the IT guy's problem. I don't imagine it's anything spectacular though. The apps get quite heavy use but I'm with Tedd on the results issue, we only see maybe 10% of the users going to page 2, but these are internal users searching company data, so the pattern may not be typical. Hope you find something you're happy with, Mark -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Search thoughts
On Sat, Jul 19, 2008 at 5:47 AM, Richard Heyes [EMAIL PROTECTED] wrote: Hey, I was hoping to get some ideas on improving a sites search. Currently I have two - not a lot but I've been thinking about this for a few minutes. Currently the site in question uses a very basic LIKE in MySQL, eg %blah%, but naturally this finds terms such as hjkblahbjkk - which is not desired. Or such matches should be ranked lower than something that matches the exact word blah. My thoughts are using a points system, eg assigning 5 points for an exact word match, 1 for a partial match. And then ordering the search results by the total points assigned. Either that or using external search code and not worrying so much. Cheers. -- Richard Heyes -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Ever play with fulltext search? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Search thoughts
Ever play with fulltext search? Yes, though it's not suitable in this instance. -- Richard Heyes -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Search thoughts
At 1:56 PM -0400 7/19/08, Eric Butera wrote: Ever play with fulltext search? Never in public. :-) You could throw all text into your database and then do a fulltext search to give back the related pages -- that would work. I think I saw that as an example in one of the books I read. PHP Cookbook shows an example of the entire King James Bible in a dB -- interesting read and demo. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Search thoughts
On Sat, Jul 19, 2008 at 3:40 PM, tedd [EMAIL PROTECTED] wrote: At 1:56 PM -0400 7/19/08, Eric Butera wrote: Ever play with fulltext search? Never in public. :-) You could throw all text into your database and then do a fulltext search to give back the related pages -- that would work. I think I saw that as an example in one of the books I read. PHP Cookbook shows an example of the entire King James Bible in a dB -- interesting read and demo. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Yea I've done a lot of compiling content and then searching against what it is supposed to be. Fulltext works really well for things like that. I've been playing around with the zend search lucene and it is really powerful too. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Search thoughts
the entire King James Bible in a dB -- interesting read That's debateable... :-) -- Richard Heyes -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Search thoughts
Hi, I've been playing around with the zend search lucene and it is really powerful too. Worth looking into? -- Richard Heyes -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Search thoughts
On Sat, Jul 19, 2008 at 4:06 PM, Richard Heyes [EMAIL PROTECTED] wrote: Hi, I've been playing around with the zend search lucene and it is really powerful too. Worth looking into? -- Richard Heyes Most definitely. But with all that power and optional stuff comes complexity too. It isn't a five minute attempt to see something working. In fact I thought it was a bit harder than it needed to be getting it working (specifically removing a document/re-adding to update). What I've done is get a really basic add/edit/remove search on partial content set up. It is pretty easy to set up a search on a site with it now. From there I can move from a timed cron job re-indexing to actual real time updates on content saving if needed. Also you can customize what exactly gets stored in the search database too. You can specify you want to search on document titles versus just the whole content. There is a lot there to play with. Before this I used either a fulltext, simple LIKE, or an external program like Swish-e. I really enjoyed using Swish-e, except it doesn't support utf-8 which is silly in 2008. http://framework.zend.com/manual/en/zend.search.lucene.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Search thoughts
http://framework.zend.com/manual/en/zend.search.lucene.html Nice one, thanks. -- Richard Heyes -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Search like php.net's URL thingy
On Thu, Jun 5, 2008 at 3:07 PM, Ryan S [EMAIL PROTECTED] wrote: Hey, one of the things that make the php.net site so cool is how easy it is to find info for a function or a list of topics.. eg: http://php.net/arrays http://php.net/count [snip!] since i couldnt find the answer via php.net's source i started messing around with how i *think* its done... tell me if i am on the correct track: when someone requests a page that does not exist, a .htaccess file them up and also takes the page name they were searching for and redirects them to a script... You're on the right track, Ryan. Look up mod_rewrite for Apache, and also consider that php.net uses operations similar to (though not exactlt like) the following procedure: #.htaccess Redirect /ciel http://php.net/manual/en/function.ceil.php -- /Daniel P. Brown Dedicated Servers - Intel 2.4GHz w/2TB bandwidth/mo. starting at just $59.99/mo. with no contract! Dedicated servers, VPS, and hosting from $2.50/mo. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Search like php.net's URL thingy
Hey! Thanks for replying. Digging a bit more i found IfModule mod_rewrite.c RewriteEngine On RewriteRule ^([a-z][0-9][A-Z][aA0-zZ0])$ jj.php?show=$1 /IfModule But it does not work :( do you see any fault with the above? Thanks! R -- - The faulty interface lies between the chair and the keyboard. - Creativity is great, but plagiarism is faster! - Smile, everyone loves a moron. :-) - Original Message From: Bernhard Kohl [EMAIL PROTECTED] To: Ryan S [EMAIL PROTECTED] Sent: Thursday, June 5, 2008 9:25:46 PM Subject: Re: [PHP] Search like php.net's URL thingy you should familiarize yourself with the rewrite module of the apache server (if u operate on that one) it's pretty much the same as regular expressions syntax example: i want all requests going to www.example.com/test being forwarded to index.php?a=test place following into your .htaccess file in the root directory: RewriteEngine on RewriteBase / RewriteRule ^([a-zA-Z])$ index.php?a=$1 the whole thing can get pretty complex with alot of rewrite conditions and stuff. good luck On 6/5/08, Ryan S [EMAIL PROTECTED] wrote: Hey, one of the things that make the php.net site so cool is how easy it is to find info for a function or a list of topics.. eg: http://php.net/arrays http://php.net/count I'm sure nearly all of you reading this have done it more times than you would care to count, i'm trying to get something like this on my own site but even after going to php.net and clicking on the view source buttons am a bit confused. basically this is what i am trying, people who type in http://www.mysite.com/asdf should not be shown a 404 not found page but instead asdf should be passed onto my script where i can do a search on the term and either give them back the results of that search or direct them to a custom 404 page. since i couldnt find the answer via php.net's source i started messing around with how i *think* its done... tell me if i am on the correct track: when someone requests a page that does not exist, a .htaccess file them up and also takes the page name they were searching for and redirects them to a script... So far i have only been able to get the .htaccess file point to my custom 404 page... but how do i get it to pass the parameter of the not-found-page to my script? Would appreciate any code, tips, urls you can give me. Thanks! Ryan -- - The faulty interface lies between the chair and the keyboard. - Creativity is great, but plagiarism is faster! - Smile, everyone loves a moron. :-) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Search engines and cookies
On Mon, Apr 7, 2008 at 9:29 AM, Emil Edeholt [EMAIL PROTECTED] wrote: Hi, Do you guys how search engines like cookies? One site I'm working on now requires the user to select which region he/she is from on the start page. That value is stored in a cookie. So without cookies you can't get past the start page. Does this leave the search engines at the start page? Right now google only index the start pages on my site and I'm trying to figure out why. If I can't use cookies, how would you force users to select a region but letting the search engine spiders in on the site somehow? One way to do it would be to allow Google (and/or other search engines) to access the site by bypassing the region-selection entirely. ?php if(preg_match('/Google/Uis',$_SERVER['HTTP_USER_AGENT'])) { // Allow Google to pass through. } ? -- /Daniel P. Brown Ask me about: Dedicated servers starting @ $59.99/mo., VPS starting @ $19.99/mo., and shared hosting starting @ $2.50/mo. Unmanaged, managed, and fully-managed! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Search engines and cookies
Search engines won't come past that page. How about setting a default region when a user enters a different page then your main page? Daniel Brown wrote: On Mon, Apr 7, 2008 at 9:29 AM, Emil Edeholt [EMAIL PROTECTED] wrote: Hi, Do you guys how search engines like cookies? One site I'm working on now requires the user to select which region he/she is from on the start page. That value is stored in a cookie. So without cookies you can't get past the start page. Does this leave the search engines at the start page? Right now google only index the start pages on my site and I'm trying to figure out why. If I can't use cookies, how would you force users to select a region but letting the search engine spiders in on the site somehow? One way to do it would be to allow Google (and/or other search engines) to access the site by bypassing the region-selection entirely. ?php if(preg_match('/Google/Uis',$_SERVER['HTTP_USER_AGENT'])) { // Allow Google to pass through. } ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Search engines and cookies
At 3:29 PM +0200 4/7/08, Emil Edeholt wrote: Hi, Do you guys how search engines like cookies? One site I'm working on now requires the user to select which region he/she is from on the start page. That value is stored in a cookie. So without cookies you can't get past the start page. Does this leave the search engines at the start page? Right now google only index the start pages on my site and I'm trying to figure out why. If I can't use cookies, how would you force users to select a region but letting the search engine spiders in on the site somehow? Hope this wasn't too off topic. Kind Regards Emil Emil: My advice -- give the SE what it's looking for. Place a description of what your site is about on the start page. If you don't want users to see it, then place the text off-left via css position. This would also help those with assistive technologies and thus SE's shouldn't complain. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Search function not working...
On 2/1/08, Jason Pruim [EMAIL PROTECTED] wrote: So I said in another thread that I would be asking another question about functions... So here it goes, I am attempting to write a function to search the database, which used to work just fine when I wrote it without using a function (Would that be considered static?) Now that I am attempting to rewrite my stuff so I can reuse the code, now it's not working... Here is what I used to do and it worked just fine: $qstring = SELECT * FROM .$table. WHERE FName like '%$search%' or LName like '%$search%' or Add1 like '%$search%' or Add2 like '%$search %' or City like '%$search%' or State like '%$search%' or Zip like '% $search%' or XCode like '%$search%'; if ($_SESSION['search'] != NULL){ echo The search string is: strong$search/strong.BR; $qrow[]= mysql_query($qstring) or die(mysql_error()); $qresult = $qrow[0]; $num_rows = mysql_num_rows($qresult); //display search form echo form action='search.php' method='GET' labelSearch: input type='text' name='search' id='search' / /label input type='submit' value='Go!' / /form; echo HTML a href='index.php'Return to database/A PTotal Records found: {$num_rows}/P A href='excelexport.php'Export selection to excel/A form method='GET' action='edit.php' table border='1' tr tha href='?order=a'First Name/A/th thA href='?order=b'Last Name/A/th thA href='?order=c'Address Line 1/A/th THA href='?order=d'Address Line 2/A/th THA href='?order=e'City/A/th thA href='?order=f'State/A/th thA href='?order=g'Zip/A/th THA href='?order=h'Code/A/th thA href='?order=i'ID #/A/th THEdit/th thDelete/th /tr HTML; echo Just testing: .$_SESSION['search']; while($qrow = mysql_fetch_assoc($qresult)) { //Display the search results using heredoc syntax echo HTML tr td{$qrow['FName']}/td td{$qrow['LName']}/td td{$qrow['Add1']}/td td{$qrow['Add2']}/td td{$qrow['City']}/td td{$qrow['State']}/td td{$qrow['Zip']}/td td{$qrow['XCode']}/td td{$qrow['Record']}/td tda href='edit.php ?Record={$qrow['Record']}'Edit/a/td tda href='delete.php ?Record={$qrow['Record']}'Delete/a/td /tr /form HTML; Now, here is what I have as a function and is not working: ?PHP $FName =; $LName =; $Add1 = ; $Add2 = ; // $_SESSION['search'] = $_GET['search']; function search($searchvar, $table, $num_rows, $FName, $LName, $Add1, $Add2) { $qstring = SELECT * FROM .$table. WHERE FName like '%$searchvar%' or LName like '%$searchvar%' or Add1 like '%$searchvar%' or Add2 like '%$searchvar%' or City like '%$searchvar%' or State like '%$searchvar%' or Zip like '%$searchvar%' or XCode like '%$searchvar%'; $qrow[]= mysql_query($qstring) or die(mysql_error()); $qresult = $qrow[0]; $num_rows = mysql_num_rows($qresult); while($qrow = mysql_fetch_assoc($qresult)) { $FName = $qrow['FName']; $LName = $qrow['LName']; $Add1 = $qrow['Add1']; $Add2 = $qrow['Add2']; } // what do you want to return...? return; } ? $returnedSomething = search($searchvar, $table, $num_rows, $FName, $LName, $Add1, $Add2); Jason, 1. You're missing a closing brace at the end of the while loop. 2. You're not returning anything from the function. The input parameters are pretty clear but what were you expecting to accomplish within the function? All the data returned from the query only have scope within the function, so unless you return something, like an array or a string, use references, or write to a global variable, you're not doing anything with the data from the db. David
Re: [PHP] Search function not working...
On Feb 1, 2008, at 2:20 PM, David Giragosian wrote: On 2/1/08, Jason Pruim [EMAIL PROTECTED] wrote: [snip long explanation of problem] function search($searchvar, $table, $num_rows, $FName, $LName, $Add1, $Add2) { $qstring = SELECT * FROM .$table. WHERE FName like '% $searchvar%' or LName like '%$searchvar%' or Add1 like '% $searchvar%' or Add2 like '%$searchvar%' or City like '%$searchvar%' or State like '%$searchvar%' or Zip like '%$searchvar%' or XCode like '% $searchvar%'; $qrow[]= mysql_query($qstring) or die(mysql_error()); $qresult = $qrow[0]; $num_rows = mysql_num_rows($qresult); while($qrow = mysql_fetch_assoc($qresult)) { $FName = $qrow['FName']; $LName = $qrow['LName']; $Add1 = $qrow['Add1']; $Add2 = $qrow['Add2']; } // what do you want to return...? return; } ? $returnedSomething = search($searchvar, $table, $num_rows, $FName, $LName, $Add1, $Add2); Jason, 1. You're missing a closing brace at the end of the while loop. 2. You're not returning anything from the function. The input parameters are pretty clear but what were you expecting to accomplish within the function? All the data returned from the query only have scope within the function, so unless you return something, like an array or a string, use references, or write to a global variable, you're not doing anything with the data from the db. David Hi David, Thanks for looking. I'm just starting to learn about functions, and obviously making a few mistakes along the road... Basically what I am trying to do is allow my customer the ability to search the database, display it on the website, and then export it to excel if they wish... the missing closing brace was a bad copy/paste job. I have tried to add $searchReturn = search($searchvar, $table, $num_rows, $FName, $LName, $Add1, $Add2); and then do a vardump on it and it's not returning any thing. I've also changed the return line to return $searchReturn['FName']; but it's still not showing through... I think functions will be the death of me... at least until I understand how to use them :) I think I'm off to google some more and see if I can get any more info... Thanks again for your help! -- Jason Pruim Raoset Inc. Technology Manager MQC Specialist 3251 132nd ave Holland, MI, 49424 www.raoset.com [EMAIL PROTECTED]
Re: [PHP] Search function not working...
On 2/1/08, Jason Pruim [EMAIL PROTECTED] wrote: On Feb 1, 2008, at 2:20 PM, David Giragosian wrote: On 2/1/08, Jason Pruim [EMAIL PROTECTED] wrote: [snip long explanation of problem] function search($searchvar, $table, $num_rows, $FName, $LName, $Add1, $Add2) { $qstring = SELECT * FROM .$table. WHERE FName like '%$searchvar%' or LName like '%$searchvar%' or Add1 like '%$searchvar%' or Add2 like '%$searchvar%' or City like '%$searchvar%' or State like '%$searchvar%' or Zip like '%$searchvar%' or XCode like '%$searchvar%'; $qrow[]= mysql_query($qstring) or die(mysql_error()); $qresult = $qrow[0]; $num_rows = mysql_num_rows($qresult); while($qrow = mysql_fetch_assoc($qresult)) { $FName = $qrow['FName']; $LName = $qrow['LName']; $Add1 = $qrow['Add1']; $Add2 = $qrow['Add2']; } // what do you want to return...? return; } ? $returnedSomething = search($searchvar, $table, $num_rows, $FName, $LName, $Add1, $Add2); Jason, 1. You're missing a closing brace at the end of the while loop. 2. You're not returning anything from the function. The input parameters are pretty clear but what were you expecting to accomplish within the function? All the data returned from the query only have scope within the function, so unless you return something, like an array or a string, use references, or write to a global variable, you're not doing anything with the data from the db. David Hi David, Thanks for looking. I'm just starting to learn about functions, and obviously making a few mistakes along the road... Basically what I am trying to do is allow my customer the ability to search the database, display it on the website, and then export it to excel if they wish... the missing closing brace was a bad copy/paste job. I have tried to add $searchReturn = search($searchvar, $table, $num_rows, $FName, $LName, $Add1, $Add2); and then do a vardump on it and it's not returning any thing. I've also changed the return line to return $searchReturn['FName']; but it's still not showing through... I think functions will be the death of me... at least until I understand how to use them :) I think I'm off to google some more and see if I can get any more info... Thanks again for your help! Jason, Untested, but try this... function search($searchvar, $table, $num_rows, $FName, $LName, $Add1, $Add2) { $qstring = SELECT * FROM .$table. WHERE FName like '%$searchvar%' or LName like '%$searchvar%' or Add1 like '%$searchvar%' or Add2 like '%$searchvar%' or City like '%$searchvar%' or State like '%$searchvar%' or Zip like '%$searchvar%' or XCode like '%$searchvar%'; $qrow = mysql_query($qstring) or die(mysql_error()); $qresult = $qrow; $num_rows = mysql_num_rows($qresult); $outputStr = table; while($qrow = mysql_fetch_assoc($qresult)) { $FName = $qrow['FName']; $LName = $qrow['LName']; $Add1 = $qrow['Add1']; $Add2 = $qrow['Add2']; $outputStr .= trtd$FName/tdtd$LName/tdtd$ADD1/tdtd$ADD2/td/tr\n; } $outputStr .= /table; return $outputStr; } $searchReturn = search($searchvar, $table, $num_rows, $FName, $LName, $Add1, $Add2); echo $searchReturn; David
Re: [PHP] Search function not working...
Jason, Untested, but try this... function search($searchvar, $table, $num_rows, $FName, $LName, $Add1, $Add2) { $qstring = SELECT * FROM .$table. WHERE FName like '%$searchvar%' or LName like '%$searchvar%' or Add1 like '%$searchvar%' or Add2 like '%$searchvar%' or City like '%$searchvar%' or State like '%$searchvar%' or Zip like '%$searchvar%' or XCode like '%$searchvar%'; $qrow = mysql_query($qstring) or die(mysql_error()); $qresult = $qrow; $num_rows = mysql_num_rows($qresult); $outputStr = table; while($qrow = mysql_fetch_assoc($qresult)) { $FName = $qrow['FName']; $LName = $qrow['LName']; $Add1 = $qrow['Add1']; $Add2 = $qrow['Add2']; $outputStr .= trtd$FName/tdtd$LName/tdtd$ADD1/tdtd$ADD2/td/tr\n; } $outputStr .= /table; return $outputStr; } $searchReturn = search($searchvar, $table, $num_rows, $FName, $LName, $Add1, $Add2); echo $searchReturn; David Hold on a moment... function search($searchvar, $table, $num_rows, $FName, $LName, $Add1, $Add2) { $qstring = SELECT * FROM .$table. WHERE FName like '%$searchvar%' or LName like '%$searchvar%' or Add1 like '%$searchvar%' or Add2 like '%$searchvar%' or City like '%$searchvar%' or State like '%$searchvar%' or Zip like '%$searchvar%' or XCode like '%$searchvar%'; $qresult = mysql_query($qstring) or die(mysql_error()); //$qresult = $qrow; // this line is the problem ! $num_rows = mysql_num_rows($qresult); $outputStr = table; while($qrow = mysql_fetch_assoc($qresult)) { $FName = $qrow['FName']; $LName = $qrow['LName']; $Add1 = $qrow['Add1']; $Add2 = $qrow['Add2']; $outputStr .= trtd$FName/tdtd$LName/tdtd$ADD1/tdtd$ADD2/td/tr\n; } $outputStr .= /table; return $outputStr; } $searchReturn = search($searchvar, $table, $num_rows, $FName, $LName, $Add1, $Add2); echo $searchReturn; That should work, assuming the query returns at least one row.. David
Re: [PHP] Search function not working...
Jason Pruim wrote: So I said in another thread that I would be asking another question about functions... So here it goes, I am attempting to write a function to search the database, which used to work just fine when I wrote it without using a function (Would that be considered static?) Now that I am attempting to rewrite my stuff so I can reuse the code, now it's not working... Here is what I used to do and it worked just fine: $qstring = SELECT * FROM .$table. WHERE FName like '%$search%' or LName like '%$search%' or Add1 like '%$search%' or Add2 like '%$search%' or City like '%$search%' or State like '%$search%' or Zip like '%$search%' or XCode like '%$search%'; if ($_SESSION['search'] != NULL){ echo The search string is: strong$search/strong.BR; $qrow[]= mysql_query($qstring) or die(mysql_error()); $qresult = $qrow[0]; $num_rows = mysql_num_rows($qresult); //display search form echo form action='search.php' method='GET' labelSearch: input type='text' name='search' id='search' / /label input type='submit' value='Go!' / /form; echo HTML a href='index.php'Return to database/A PTotal Records found: {$num_rows}/P A href='excelexport.php'Export selection to excel/A form method='GET' action='edit.php' table border='1' tr tha href='?order=a'First Name/A/th thA href='?order=b'Last Name/A/th thA href='?order=c'Address Line 1/A/th THA href='?order=d'Address Line 2/A/th THA href='?order=e'City/A/th thA href='?order=f'State/A/th thA href='?order=g'Zip/A/th THA href='?order=h'Code/A/th thA href='?order=i'ID #/A/th THEdit/th thDelete/th /tr HTML; echo Just testing: .$_SESSION['search']; while($qrow = mysql_fetch_assoc($qresult)) { //Display the search results using heredoc syntax echo HTML tr td{$qrow['FName']}/td td{$qrow['LName']}/td td{$qrow['Add1']}/td td{$qrow['Add2']}/td td{$qrow['City']}/td td{$qrow['State']}/td td{$qrow['Zip']}/td td{$qrow['XCode']}/td td{$qrow['Record']}/td tda href='edit.php?Record={$qrow['Record']}'Edit/a/td tda href='delete.php?Record={$qrow['Record']}'Delete/a/td /tr /form HTML; Now, here is what I have as a function and is not working: ?PHP $FName =; $LName =; $Add1 = ; $Add2 = ; //$_SESSION['search'] = $_GET['search']; function search($searchvar, $table, $num_rows, $FName, $LName, $Add1, $Add2) { $qstring = SELECT * FROM .$table. WHERE FName like '%$searchvar%' or LName like '%$searchvar%' or Add1 like '%$searchvar%' or Add2 like '%$searchvar%' or City like '%$searchvar%' or State like '%$searchvar%' or Zip like '%$searchvar%' or XCode like '%$searchvar%'; $qrow[]= mysql_query($qstring) or die(mysql_error()); $qresult = $qrow[0]; $num_rows = mysql_num_rows($qresult); //while($qrow = mysql_fetch_assoc($qresult)) { $FName = $qrow['FName']; $LName = $qrow['LName']; $Add1 = $qrow['Add1']; $Add2 = $qrow['Add2']; return; } ? And what happens, is first of all it displays the entire database on the search page, which I'm kind of okay with... But when you search, it updates the variables, and echo's out the right search term, but it doesn't update the database to only show the search results... I think it might be tied to it displaying the entire database at page load... But I'm not sure.. Anyone have an idea of what I did wrong other then everything? :) Oh, and as far as calling the function I do this: search($searchvar, $table, $num_rows, $FName, $LName, $Add1, $Add2); -- Jason Pruim Raoset Inc. Technology Manager MQC Specialist 3251 132nd ave Holland, MI, 49424 www.raoset.com [EMAIL PROTECTED] Ok, here would be my rendition of this function. ?php function search($searchvar, $table) { // Since we want to ensure that we have good data before we run our // query, we want to clear our search data before we use it $clean_searchvar = mysql_real_escape_string($searchvar); // Build our SQL statement $SQL = SELECT * FROM{$table} WHERE FName LIKE '%{$clean_searchvar}%' OR LName LIKE '%{$clean_searchvar}%' OR Add1LIKE '%{$clean_searchvar}%' OR Add2LIKE '%{$clean_searchvar}%' OR CityLIKE '%{$clean_searchvar}%' OR State LIKE '%{$clean_searchvar}%' OR Zip LIKE '%{$clean_searchvar}%' OR XCode LIKE '%{$clean_searchvar}%'; // Process SQL statement, continue on success or display error $res = mysql_query($SQL) or die(mysql_error());
Re: [PHP] Search function
On Wed, May 9, 2007 7:34 am, Ryan A wrote: Now they want to add a search function to the site... a simpe textbox where a user enters a word or sentance and they get 20 results per page... with a x.xx % closest to your query can anybody give me basic pointers on where to start? Any links/software or articles too would be appreciated... You could google for full text search and weighted search and find more than enough reading to fill the rest of your life... :-) With only a couple hundred pages of content, it's kinda hard to really make a good search engine... You'd almost be better off just building a form that leads to Google and using theirs, really. -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Search function
Ryan A wrote: Hey! .A little background: We have a site that has already been made.. a couple of hundred pages displayed via SMARTY templates, the site's in Swedish. The navigation and other parts except for the center is taken care of by the templates and other scripts... the center main text is taken from the database(mySql) based on $page_id...its in a MySql TEXT field and has all the html etc that will be displayed in the center of the page. End of background.. Now they want to add a search function to the site... a simpe textbox where a user enters a word or sentance and they get 20 results per page... with a x.xx % closest to your query can anybody give me basic pointers on where to start? Any links/software or articles too would be appreciated... http://dev.mysql.com/doc/refman/4.1/en/fulltext-search.html Start off with that, if they need something more complicated down the line, revisit. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Search script problem
Wikus Moller wrote: Hi. I am having problems with a script I wrote which searches keywords from a field in a mysql db table. It is a very simple, one-page script. My site is a toplist, very basic, still in it's infancy. When I go to the page, key in the keywords and press submit, the head, body etc. part of the result script is shown, but no results. , although there are rows in my database containing the `keyword` field data. Below is the script, please see if you find any errors, it could be that I just made a stupid mistake. imho your first stupid mistake was writing a script that bloody unmanagable. 1. check you input 2. do some processing 3. ouput your page (including any error msgs from step 1 and 2) this is in contrast to the tactic your using, namely: dump some output, do something, dump more output, perform a query, dump some output, do stuff, dump some output in a loop, do stuff, dump some output, etc. P. read on ... ?php echo ?xml version=\1.0\ encoding=\UTF-8\?; echo !DOCTYPE HTML PUBLIC \-//W3C//DTD XHTML Mobile 1.0//EN\ \http://www.wapforum.org/DTD/xhtml-mobile10.dtd\;; echo html xmlns=\http://www.w3.org/1999/xhtml\;; error_reporting(E_ALL ^ E_NOTICE); $pwd = $_GET[pwd]; $uid = $_GET[uid]; $action = $_GET[action]; $cid = $_GET[cid]; $sid = $_GET[sid]; $var = $_GET[q]; echo 'is this your expected input? : pre'; var_dump($_GET) echo '/pre'; include (function.php); include (config.php); connect($dbserver,$dbname,$dbuser,$dbpass); /Search main page if(!isset($var)){ echo head; echo titleSearch Engine/title; echo style type=\text/css\ .m3 {background-color: #291C6F;} .n1 {background-color: #A0A0A0;} .n2 {background-color: #88;} .c2 {color: #00;} .m2 {color: #91D0FF;} body {font-family: Arial, sans-serif; font-size: 12px; color: #ff; background-color: #33; margin-left: 0px; margin-right: 0px; margin-top: 0px;} .ct1 {font-family: Arial, sans-serif; font-size: 12px; color: #800080;} .cre {background-color: #1300A4; padding: 2px 2px 2px 2px; margin: 3px 0 0; font-size: 12px; color:#00; text-align: center; border-width:1px 0; border-style:solid; border-color:#00;} use a css file and save a bit of band width (and scrolling in my case). /style; echo /head; echo body; echo table; echo div class=\cre\; echo bSearch Engine/b/div; echo form method=\GET\ action=\search.php?uid=$uidamp;pwd=$pwd\; ///the uid and pwd is nessecary cause my member features are very basic and the urls is used to keep the user 'logged in' basic is the wrong word if your are thinking in terms of security - non-existent is closer to the truth. http://phpsec.org is a good place to and learn about security on all [php] fronts echo Keywords: input type=\text\ name=\q\ /br/; echo input type=\submit\ name=\Submit\/; echo /form; echo /table; echo div class=\cre\img src=\images/home.gif\ alt=\*\/a href=\index.php?uid=$uidamp;pwd=$pwd\Home/a/div; echo /body; echo /html; } ///Display Results if(isset($var)){ the following line is pointless given the line about and the fact that you have already set $var in exactly the same way at the top of your script. $var = $_GET[q]; $trimmed = trim($var); //trim whitespace from the stored variable echo head; echo titleSearch Results/title; echo style type=\text/css\ .m3 {background-color: #291C6F;} .n1 {background-color: #A0A0A0;} .n2 {background-color: #88;} .c2 {color: #00;} .m2 {color: #91D0FF;} body {font-family: Arial, sans-serif; font-size: 12px; color: #ff; background-color: #33; margin-left: 0px; margin-right: 0px; margin-top: 0px;} .ct1 {font-family: Arial, sans-serif; font-size: 12px; color: #800080;} .cre {background-color: #1300A4; padding: 2px 2px 2px 2px; margin: 3px 0 0; font-size: 12px; color:#00; text-align: center; border-width:1px 0; border-style:solid; border-color:#00;} /style; echo /head; echo body; echo div class=\cre\; echo bSearch Results/b/div; echo table; // Get the search variable from URL // check for an empty string and display a message. if ($trimmed == ) { echo Please enter a search...; exit; } if($pg==0)$pg=1; $pg--; $lmt = $pg*20; $pg++; $cou =$lmt+1; is your table called 'table'? that is the WORST name in the world for a table - and it will break your queries unless you stick them in
Re: [PHP] Search script problem
please keep it on the list. Wikus Moller wrote: Let me repeat myself, SIMPLE, this was just the starting point. niether 'simple' or 'starting point' equate to 'ugly' or 'shit' though do they. even simple scripts deserve error checking and a managable layout. I wasn't pointing that out to make you feel bad but to give you a leg up in better script writing ... The error was caused due to a field being created after there were already rows in the table. that *shouldn't* cause you any errors. the most likely reason it did is your scripts assumption of the physical field order of your table. I would recommend not using mysql_fetch_array() instead switch to mysql_fetch_assoc() and reference the elements in the returned array by name rather than by number - this has 2 advantages: 1. you won't get bitten by fields that were added to the table after the script was written. 2. the output you generate using the returned array is alot more understandable: e.g. $row['name'] as compared to $row[0] It works like a dream and now I will correct the errors you pointed out and which you assumed I didn't know and which had no relevance to my query after I stated so boldly that it was simple. a. I merely assumed that you *may* not be aware of the things I pointed out, if you are aware of those points then there was really no harm done, if you weren't then you would have been armed some new info ... b. you can't control the answer, only the question, stop trying :-) Thanks ... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Search script problem
top posting. what sucks? - still having trouble keeping your posts on lists? if you want to put me in my place, that's fine but please keep it on list where it belongs - if only because private flames wars are so boring. Wikus Moller wrote: Oops, I gave you the wrong link, here is the correct one where you can gain some knowledge: http://google.com/search?q=How+to+answer+questions+without+trying+to+look+smart firstly, I can't actually see anything very specific to the query in the results. secondly the first item in the results is primarily aimed at *you* (given that you asked the question). with regard to this page: http://catb.org/~esr/faqs/smart-questions.html I am aware of it, I've read it a number of times, it's been posted on this list numerous times and at least 1 long time list member actually carries the link in his signature. with regard to the last section on that page entitled 'How To Answer Questions in a Helpful Way' I don't feel I transgressed any on of the points made, other than possibly 'be gentle' - obviously you didn't consider it a gentle reply but it was comparitively gentle by my usual standards. with regard to looking smart - I don't kind looking smart at all, I consider myself smart *reasonably* knowledge with regard to using php - not perfect, not gifted, not exceptional in anyway, but smart nonetheless. if that makes you feel inferior you have one simple recourse - become, in your mind, smarter than me :-) I'll welcome it, it would mean one more mind on this list capable of solving problems and help raise the level of php hacking in general. On 1/8/07, Wikus Moller [EMAIL PROTECTED] wrote: Thats fine with me ^.^ Here are some tips for you when you answer a question next time: http://google.com/search?p=How+to+answer+a+question+without+trying+to+look+smart Thanks Wikus On 1/7/07, Jochem Maas [EMAIL PROTECTED] wrote: please keep it on the list. Wikus Moller wrote: Let me repeat myself, SIMPLE, this was just the starting point. niether 'simple' or 'starting point' equate to 'ugly' or 'shit' though do they. even simple scripts deserve error checking and a managable layout. I wasn't pointing that out to make you feel bad but to give you a leg up in better script writing ... The error was caused due to a field being created after there were already rows in the table. that *shouldn't* cause you any errors. the most likely reason it did is your scripts assumption of the physical field order of your table. I would recommend not using mysql_fetch_array() instead switch to mysql_fetch_assoc() and reference the elements in the returned array by name rather than by number - this has 2 advantages: 1. you won't get bitten by fields that were added to the table after the script was written. 2. the output you generate using the returned array is alot more understandable: e.g. $row['name'] as compared to $row[0] It works like a dream and now I will correct the errors you pointed out and which you assumed I didn't know and which had no relevance to my query after I stated so boldly that it was simple. a. I merely assumed that you *may* not be aware of the things I pointed out, if you are aware of those points then there was really no harm done, if you weren't then you would have been armed some new info ... b. you can't control the answer, only the question, stop trying :-) Thanks ... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Search Results Accuracy
Hi, I'm not really sure which is the best path to go but let me give you an example scenario : 1. We already have a database of varchar data : +---+ | links | +---+ | 340-golfers-dream-and-swimmers| +---+ | 89-golfers-dream | +---+ | 45-golf-equipments| +---+ | 3-best-golf-training | +---+ | 0-golf-equipment-and-training | +---+ | 39-golf-training | +---+ 2. From data above if we search the database for '%golf%' it would return all rows as results, if we search for '%golf%training%' it would return three rows . How do I choose from the multiple results? For the '%golf%' query, the desired result is golf-equipments or golf-training, while for '%golf%training%' the desired result should be 39-golf-training alone . This is sort of like search engine ranking their results, but for this how do I set the criteria using MySQL queries or if not possible using PHP . I hope it makes it more clear, questions are welcomed. TIA Jervin -- Outsource Now | GetAFreelancer http://www.getafreelancer.com/affiliates/shockx/ _ From: Shafiq Rehman [mailto:[EMAIL PROTECTED] Sent: Tuesday, December 19, 2006 2:07 PM To: zoticaic Subject: Re: [PHP] Search Results Accuracy Hello, Your question is not very clear, please elaborate it. btw, Are you talking about the fulltext search? -- Shafiq Rehman Sr. Web Engineer http://www.phpgurru.com http://www.phpgurru.com On 12/19/06, zoticaic [EMAIL PROTECTED] wrote: Hello, I'm just wondering, from a list of search results from a database query, how do we trim down and return the most accurate one? Hints, links and suggestions are most welcome. TIA Jervin -- Outsource Now | GetAFreelancer http://www.getafreelancer.com/affiliates/shockx/
Re: [PHP] Search Results Accuracy
# [EMAIL PROTECTED] / 2006-12-19 09:33:02 +0800: Hello, I'm just wondering, from a list of search results from a database query, how do we trim down and return the most accurate one? Hints, links and suggestions are most welcome. is this what you're looking for? http://dev.mysql.com/doc/refman/5.0/en/fulltext-search.html -- How many Vietnam vets does it take to screw in a light bulb? You don't know, man. You don't KNOW. Cause you weren't THERE. http://bash.org/?255991 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Search Results Accuracy
Thanks, All I needed was that to get started with. Regards jervin -- Outsource Now | GetAFreelancer http://www.getafreelancer.com/affiliates/shockx/ _ From: Shafiq Rehman [mailto:[EMAIL PROTECTED] Sent: Tuesday, December 19, 2006 2:41 PM To: zoticaic Subject: Re: [PHP] Search Results Accuracy Hello, In searching, like queries are not recommended because these are the most slowest queries. You must use full text searching. It will rocks your search speed and suits your scenario. Here is an article for fulltext searching http://www.onlamp.com/pub/a/onlamp/2003/06/26/fulltext.html -- Shafiq Rehman Sr. Web Engineer http://www.phpgurru.com On 12/19/06, zoticaic [EMAIL PROTECTED] wrote: Hi, I'm not really sure which is the best path to go but let me give you an example scenario : 1. We already have a database of varchar data : +---+ | links | +---+ | 340-golfers-dream-and-swimmers| +---+ | 89-golfers-dream | +---+ | 45-golf-equipments| +---+ | 3-best-golf-training | +---+ | 0-golf-equipment-and-training | +---+ | 39-golf-training | +---+ 2. From data above if we search the database for '%golf%' it would return all rows as results, if we search for '%golf%training%' it would return three rows . How do I choose from the multiple results? For the '%golf%' query, the desired result is golf-equipments or golf-training, while for '%golf%training%' the desired result should be 39-golf-training alone . This is sort of like search engine ranking their results, but for this how do I set the criteria using MySQL queries or if not possible using PHP . I hope it makes it more clear, questions are welcomed. TIA Jervin -- Outsource Now | GetAFreelancer http://www.getafreelancer.com/affiliates/shockx/ _ From: Shafiq Rehman [mailto: [EMAIL PROTECTED] Sent: Tuesday, December 19, 2006 2:07 PM To: zoticaic Subject: Re: [PHP] Search Results Accuracy Hello, Your question is not very clear, please elaborate it. btw, Are you talking about the fulltext search? -- Shafiq Rehman Sr. Web Engineer http://www.phpgurru.com http://www.phpgurru.com On 12/19/06, zoticaic [EMAIL PROTECTED] wrote: Hello, I'm just wondering, from a list of search results from a database query, how do we trim down and return the most accurate one? Hints, links and suggestions are most welcome. TIA Jervin -- Outsource Now | GetAFreelancer http://www.getafreelancer.com/affiliates/shockx/
Re: [PHP] search string
You can use a regular expressions with a function called preg_match to find the values. For example, (Assuming your sql statement is $sql) preg_match(/(tbl_chassis.chasis_model LIKE \'\%[a-zA-Z0-9-]+\%\'/), $sql, $matches); That will return $matches[0] with the matched data. Similarly, preg_match(/(AND lower\(country\) = lower\(trim\(\'(\w+)\'\)\))/, $sql, $matches); does the same thing, again in $matches[0]. The full description of preg_match can be found here: http://us2.php.net/manual/en/function.preg-match.php On 7/20/06, weetat [EMAIL PROTECTED] wrote: Hi all , I am using php4.3.2,MYSQL and RedHat I have a sql text as shown below: SELECT DISTINCT(tbl_chassis.serial_no),tbl_chassis.host_name,tbl_chassis.chasis_model,tbl_chassis.country,tbl_chassis.city,tbl_chassis.building, tbl_chassis.other,tbl_chassis.status,tbl_chassis.chasis_eos,tbl_chassis.chasis_eol,tbl_chassis.chasis_user_field_1,tbl_chassis.chasis_user_field_2,tbl_chassis.chasis_user_field_3 from tbl_chassis tbl_chassis,tbl_card tbl_card WHERE tbl_chassis.serial_no = tbl_card.serial_no AND tbl_chassis.chasis_model LIKE '%WS-C5500%' AND lower(country) = lower(trim('Malaysia')) ORDER BY country,city,building,other I need to extract the tbl_chassis.chasis_model LIKE '%WS-C5500%' and lower(country) = lower(trim('Malaysia')) and join them to new string. Anyone have any suggestion how to do this? Thanks -weetat -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Search files in a directory!
Hey, Checkout the following example. This example lists the directory content; you can do a simple string matching. http://www.weberdev.com/get_example-1572.html Thanks, Richard Correia -Original Message- From: Nicholas Couloute [mailto:[EMAIL PROTECTED] Sent: Monday, January 23, 2006 6:15 PM To: php-general@lists.php.net Subject: [PHP] Search files in a directory! I want to setup a search box that will search all the filenames in a given directory for the keyword provided by the user and display all the files that have that keyword? how would I do this? at least the searching part? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: PHP Search Engine
HI All, Has anyone on here created a search engine in PHP? I have project to create a search engine that will search about 50K or so pages of information on 100 or so various domain names. What have you all done in the past? PHPdig was a failure. Do you recommend any of the ones that are for sale? Thanks, -- Leonard Burton, N9URK [EMAIL PROTECTED] http://www.xapian.org/ Nadim Attari -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: PHP search
Bruce Gilbert wrote: Hello, I am fairly new to PHP, and I am looking to create a search functionality on a website using php. Can anyone point me to a good tutorial that can walk me through this? Between Google / Codewalkers / PHPFreaks you should be able to find something. -- NEW? | http://www.catb.org/~esr/faqs/smart-questions.html STFA | http://marc.theaimsgroup.com/?l=php-generalw=2 STFM | http://php.net/manual/en/index.php STFW | http://www.google.com/search?q=php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Search problem
Hi, I need to build up a search module for a shop. If I make a basic search (product title for example) it is ok. $query = SELECT product_id FROM products WHERE title LIKE '%$title%'; But i need an advance search for more than one field (title, description, price, weight) The problem is that i don't know which field is filled in by the user (title, description, price or weight) I mean, the user can fill in all fields, or only price field, or title and weight etc How can i do the search? Thanks $query = SELECT product_id FROM products WHERE title LIKE '%$title%' and description LIKE '%$description%' and price like '%$price%' and weight like '%weight%'; JM -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Search problem
Jim Moseby wrote: Hi, I need to build up a search module for a shop. If I make a basic search (product title for example) it is ok. $query = SELECT product_id FROM products WHERE title LIKE '%$title%'; But i need an advance search for more than one field (title, description, price, weight) The problem is that i don't know which field is filled in by the user (title, description, price or weight) I mean, the user can fill in all fields, or only price field, or title and weight etc How can i do the search? Thanks $query = SELECT product_id FROM products WHERE title LIKE '%$title%' and description LIKE '%$description%' and price like '%$price%' and weight like '%weight%'; JM While this query would work, using a fulltext index would give you a much more powerful search. Check to see if your database offers some sort of text indexing (it probably does!) Suppose you have a product title like The Lion, the Witch, and the Wardrobe. If your user did a search on lion witch wardrobe, you'd want my example to show up. Just comparing these fields with a LIKE will not give you my result, unless you explode the search string and create several LIKE statements based the individual terms, but then you have to do three LIKE comparisons, which will probably be slower than a full text index. If you are able to use a full text index, then you can write queries like this: $sql = 'SELECT * FROM products WHERE MATCH ( product_title ) AGAINST ( ' .$_REQUEST['product_title']. ' ) AND MATCH ( product_description ) AGAINST ( ' .$_REQUEST['product_description']. ' )'; which would give you The Lion, the Witch, and the Wardrobe if search terms were lion witch wardrobe. kgt
Re: [PHP] Search problem
On Sat, May 21, 2005 1:35 pm, [EMAIL PROTECTED] said: I need to build up a search module for a shop. If I make a basic search (product title for example) it is ok. $query = SELECT product_id FROM products WHERE title LIKE '%$title%'; But i need an advance search for more than one field (title, description, price, weight) The problem is that i don't know which field is filled in by the user (title, description, price or weight) I mean, the user can fill in all fields, or only price field, or title and weight etc You can use http://php.net/strlen to determine if the user has typed anything into any given INPUT. Or, if you want a simple search with only one INPUT, something like: $query = select product_id from products where 1 = 0 ; $words = explode(' ', $input); while (list(, $word) = each($words)){ $query .= or title like '%$word%' ; $query .= or description like '%$word%' ; . . . } -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Search problem
I used to search the same way until someone on this list mentioned using a fulltext index in mysql. Doing this almost eliminated all my headaches with searching. Easiest way to create a fulltext index is to use phpMyAdmin. Once you've created the fulltext index on `title`,`description`,`price`,`weight` you can then search all columns (much faster than the other way I might add) by using a simply SQL query such as this: $sql = SELECT * FROM `products` WHERE MATCH(`title`,`description`,`price`,`weight`) AGAINST (' . mysql_escape_string($_GET['query']) . '); More on FULLTEXT can be found here: http://dev.mysql.com/doc/mysql/en/fulltext-search.html Hope that helps! -Joe W. www.joewollard.com http://www.joewollard.com [EMAIL PROTECTED] wrote: Hi, I need to build up a search module for a shop. If I make a basic search (product title for example) it is ok. $query = SELECT product_id FROM products WHERE title LIKE '%$title%'; But i need an advance search for more than one field (title, description, price, weight) The problem is that i don't know which field is filled in by the user (title, description, price or weight) I mean, the user can fill in all fields, or only price field, or title and weight etc How can i do the search? Thanks
Re: [PHP] Search problem
On 5/21/05, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hi, I need to build up a search module for a shop. If I make a basic search (product title for example) it is ok. $query = SELECT product_id FROM products WHERE title LIKE '%$title%'; But i need an advance search for more than one field (title, description, price, weight) The problem is that i don't know which field is filled in by the user (title, description, price or weight) Without error checking, or security code(ie supplied code contains SQL injection vulnerability): $sql = SELECT product_id FROM products WHERE ; if($_GET['title']){ $sql_ext[] = title like '%{$_GET['title']}%' ; } if($_GET['description']){ $sql_ext[] = description like '%{$_GET['description']}%' ; } $sql .= implode( OR , $sql_ext ); I mean, the user can fill in all fields, or only price field, or title and weight etc How can i do the search? Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Search Agents...
On Thu, April 28, 2005 3:17 pm, Nick Zukin said: I have a request from a client that has me a little confounded. He wants to have a system where when someone posts a public request with certain criteria, that criteria is then used to find established profiles/agents that fit the criteria. Then emails are sent out to the people corresponding to those profiles/agents. An example: Someone posts an ad saying they have a car for sale: MODEL: Chevy MAKE: Silverado YEAR: 2005 Meanwhile, potential clients have saved search agents so that when a car is posted if the description meets their criteria they are sent an email. Thus, you could have three people, each with agents such as these: PERSON1 MODEL: Chevy MAKE: Silverado YEAR (Newer than): 2003 PERSON2 MODEL: Chevy MAKE: Any YEAR (Newer than): 2004 PERSON3 MODEL: Any MAKE: Any YEAR (Newer than): 2000 You would like all of these people to be emailed after the ad is posted, but how? This won't work: SELECT * FROM agents WHERE mymodel = Chevy AND mymake = Silverado AND myyear = 2005 But this will: WHERE (mymodel = 'Chevy' OR mymodel = 'Any') AND (mymake = 'Silverado' OR mymake = 'Any') AND (myyear = 2005 OR myyear IS NULL) You probably should use NULL to represent 'Any' and just use IS NULL in all three. It will limit the results too much. But neither will this: SELECT * FROM agents WHERE mymodel = Chevy OR mymake = Silverado OR myyear = 2005 That will give too many results. If you had a profile such as: PERSON4 MODEL: Chevy MAKE: Corvette YEAR (Newer than): 2003 They would be sent the email, too. But they aren't looking for trucks. This, at least, is clearly addressed by the above. I can't guarantee it will address *EVERY* profile -- Only time and practice will tell you that. Two options I see would be to: 1) Do it in reverse. Each time a new ad is posted to then loop through the agents doing a search for the criteria and limiting the search to only the previously posted ad, such as: SELECT * FROM ads WHERE admodel = Chevy AND admake = Silverado AND adyear = 2003 AND adid = 8 This won't work any better if the ad doesn't bother to list Make or Year or... Plus, you haven't really addressed the issue of somebody who wants a Chevy (no make specified) newer than 2003. 2) Create some crazily complex query with nested ands and ors out the wazoo. I wouldn't say my query was crazily complex... But if it is, then so be it. Is there something I'm not seeing? Is there a better way? If not, which of these seems like less of a strain on the server? Create keys on all the search columns. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Search Engine with MySQL
Phillip S. Baker wrote: Greetings all, I just serached the records and found this topic. This nearly answers my question but not completely. I have a search field and a class that I found that will explode queries into an array based on boolean values and such. Which is great so I get all the words a person is searching on and in what way. However I am not clear on the best way to query MySQL. I want to search over four fields in 2 different tables. Based on what I read below there is an easy way to do with with MySQL but I am not familiar with it. Can someone enlighten me on this, it sounds just like what I need. You could... Create a new table which smushes all the fields into one big field, and then has IDs back to the original records, and then use fulltext index on that new table. Use fulltext index on each field separately and sort/merge results in your query. There's no Magic Bullet (that I know of) for MySQL to do it though. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Search engine
On Thu, 20 Jan 2005 14:04:44 +0200, Rosen [EMAIL PROTECTED] wrote: Hi, Can someone recommend me a search engine script in PHP for inside one site? http://www.phpdig.net/ Regards, Jordi -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Search engine
This kind of depends on what database you are using (I am asuming you mean you have a data driven site you want to search so strictly speaking it is the database that you want to search). Mysl has free text search facilities (i.e. you can pass it a number of words and it can search for them in a set of database fields and even kreates a 'ranking'). however this only works if you have a few hundread records - less than this and the results are unpredictable. Have you tries googeling for php search scripts? Ben On Thu, 20 Jan 2005 14:04:44 +0200, Rosen [EMAIL PROTECTED] wrote: Hi, Can someone recommend me a search engine script in PHP for inside one site? Thanks in advance! Rosen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Ben Edwards - Poole, UK, England WARNING:This email contained partisan views - dont ever accuse me of using the veneer of objectivity If you have a problem emailing me use http://www.gurtlush.org.uk/profiles.php?uid=4 (email address this email is sent from may be defunct) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Search engine
I try many scripts for searching, but they don't work how I want. The problem is, that part of site is static text ( not in database ) , other part ( products ) are in MySQL database - this part is generating from PHP scripts. Ben Edwards [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] This kind of depends on what database you are using (I am asuming you mean you have a data driven site you want to search so strictly speaking it is the database that you want to search). Mysl has free text search facilities (i.e. you can pass it a number of words and it can search for them in a set of database fields and even kreates a 'ranking'). however this only works if you have a few hundread records - less than this and the results are unpredictable. Have you tries googeling for php search scripts? Ben On Thu, 20 Jan 2005 14:04:44 +0200, Rosen [EMAIL PROTECTED] wrote: Hi, Can someone recommend me a search engine script in PHP for inside one site? Thanks in advance! Rosen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Ben Edwards - Poole, UK, England WARNING:This email contained partisan views - dont ever accuse me of using the veneer of objectivity If you have a problem emailing me use http://www.gurtlush.org.uk/profiles.php?uid=4 (email address this email is sent from may be defunct) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Search engine
Looks like you will have to write your own. Have a look at the scripts you have and see how they do it. One option is to write the 'static' pages into the database as well as the file system. I personaly put all content into a database and do not really have any static pages atall. Ben On Thu, 20 Jan 2005 14:18:49 +0200, Rosen [EMAIL PROTECTED] wrote: I try many scripts for searching, but they don't work how I want. The problem is, that part of site is static text ( not in database ) , other part ( products ) are in MySQL database - this part is generating from PHP scripts. Ben Edwards [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] This kind of depends on what database you are using (I am asuming you mean you have a data driven site you want to search so strictly speaking it is the database that you want to search). Mysl has free text search facilities (i.e. you can pass it a number of words and it can search for them in a set of database fields and even kreates a 'ranking'). however this only works if you have a few hundread records - less than this and the results are unpredictable. Have you tries googeling for php search scripts? Ben On Thu, 20 Jan 2005 14:04:44 +0200, Rosen [EMAIL PROTECTED] wrote: Hi, Can someone recommend me a search engine script in PHP for inside one site? Thanks in advance! Rosen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Ben Edwards - Poole, UK, England WARNING:This email contained partisan views - dont ever accuse me of using the veneer of objectivity If you have a problem emailing me use http://www.gurtlush.org.uk/profiles.php?uid=4 (email address this email is sent from may be defunct) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Ben Edwards - Poole, UK, England WARNING:This email contained partisan views - dont ever accuse me of using the veneer of objectivity If you have a problem emailing me use http://www.gurtlush.org.uk/profiles.php?uid=4 (email address this email is sent from may be defunct) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Search engine
But here the problem is, that the texts in database uses from different scripts and on the search engine I should show and link to the sctipt, thath shows searched data. My idea was for search script, who explore the whole site (as generated from PHP scripts - via links ). Ben Edwards [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Looks like you will have to write your own. Have a look at the scripts you have and see how they do it. One option is to write the 'static' pages into the database as well as the file system. I personaly put all content into a database and do not really have any static pages atall. Ben On Thu, 20 Jan 2005 14:18:49 +0200, Rosen [EMAIL PROTECTED] wrote: I try many scripts for searching, but they don't work how I want. The problem is, that part of site is static text ( not in database ) , other part ( products ) are in MySQL database - this part is generating from PHP scripts. Ben Edwards [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] This kind of depends on what database you are using (I am asuming you mean you have a data driven site you want to search so strictly speaking it is the database that you want to search). Mysl has free text search facilities (i.e. you can pass it a number of words and it can search for them in a set of database fields and even kreates a 'ranking'). however this only works if you have a few hundread records - less than this and the results are unpredictable. Have you tries googeling for php search scripts? Ben On Thu, 20 Jan 2005 14:04:44 +0200, Rosen [EMAIL PROTECTED] wrote: Hi, Can someone recommend me a search engine script in PHP for inside one site? Thanks in advance! Rosen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Ben Edwards - Poole, UK, England WARNING:This email contained partisan views - dont ever accuse me of using the veneer of objectivity If you have a problem emailing me use http://www.gurtlush.org.uk/profiles.php?uid=4 (email address this email is sent from may be defunct) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Ben Edwards - Poole, UK, England WARNING:This email contained partisan views - dont ever accuse me of using the veneer of objectivity If you have a problem emailing me use http://www.gurtlush.org.uk/profiles.php?uid=4 (email address this email is sent from may be defunct) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Search engine
Why not use PHP to create static pages from your dynamic info (say 5 minutes after the data is update?) and allow for the system to search the site then? I have noticed that I don't even have to do that for the search spiders from Google and yahoo to trawl my site and get everything, so maybe looking for code to curl through would be good? Robert Rosen is quoted as saying on 1/20/2005 7:48 AM: But here the problem is, that the texts in database uses from different scripts and on the search engine I should show and link to the sctipt, thath shows searched data. My idea was for search script, who explore the whole site (as generated from PHP scripts - via links ). Ben Edwards [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Looks like you will have to write your own. Have a look at the scripts you have and see how they do it. One option is to write the 'static' pages into the database as well as the file system. I personaly put all content into a database and do not really have any static pages atall. Ben On Thu, 20 Jan 2005 14:18:49 +0200, Rosen [EMAIL PROTECTED] wrote: I try many scripts for searching, but they don't work how I want. The problem is, that part of site is static text ( not in database ) , other part ( products ) are in MySQL database - this part is generating from PHP scripts. Ben Edwards [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] This kind of depends on what database you are using (I am asuming you mean you have a data driven site you want to search so strictly speaking it is the database that you want to search). Mysl has free text search facilities (i.e. you can pass it a number of words and it can search for them in a set of database fields and even kreates a 'ranking'). however this only works if you have a few hundread records - less than this and the results are unpredictable. Have you tries googeling for php search scripts? Ben On Thu, 20 Jan 2005 14:04:44 +0200, Rosen [EMAIL PROTECTED] wrote: Hi, Can someone recommend me a search engine script in PHP for inside one site? Thanks in advance! Rosen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Ben Edwards - Poole, UK, England WARNING:This email contained partisan views - dont ever accuse me of using the veneer of objectivity If you have a problem emailing me use http://www.gurtlush.org.uk/profiles.php?uid=4 (email address this email is sent from may be defunct) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Ben Edwards - Poole, UK, England WARNING:This email contained partisan views - dont ever accuse me of using the veneer of objectivity If you have a problem emailing me use http://www.gurtlush.org.uk/profiles.php?uid=4 (email address this email is sent from may be defunct) -- Robert Sossomon, Business and Technology Application Technician 4-H Youth Development Department 200 Ricks Hall, Campus Box 7606 N.C. State University Raleigh NC 27695-7606 Phone: 919/515-8474 Fax: 919/515-7812 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Search indexing.. Re: [PHP] Search engine
Just out of curiosity.. relating to this subject.. does anyone have any good documentation on creating your own site index so you can create your own search engine? That is.. do search engines like Google take every word in a web page and if you search for that specific word it has a list of all URLs whose pages contain that word? I mean, what is the general theory behind creating a searchable index as opposed to just storing all your web pages in a database and using SQL to find the pages? If you indexed the pages you could then do a sort by relevance (which you really can't do with just doing a 'LIKE' SQL query on your raw content). I know this isn't strictly PHP related, but if someone hasn't done a basic indexing search engine in PHP, then it's time someone did I think. :) -TG = = = Original message = = = Why not use PHP to create static pages from your dynamic info (say 5 minutes after the data is update?) and allow for the system to search the site then? I have noticed that I don't even have to do that for the search spiders from Google and yahoo to trawl my site and get everything, so maybe looking for code to curl through would be good? Robert Rosen is quoted as saying on 1/20/2005 7:48 AM: But here the problem is, that the texts in database uses from different scripts and on the search engine I should show and link to the sctipt, thath shows searched data. My idea was for search script, who explore the whole site (as generated from PHP scripts - via links ). Ben Edwards [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Looks like you will have to write your own. Have a look at the scripts you have and see how they do it. One option is to write the 'static' pages into the database as well as the file system. I personaly put all content into a database and do not really have any static pages atall. Ben On Thu, 20 Jan 2005 14:18:49 +0200, Rosen [EMAIL PROTECTED] wrote: I try many scripts for searching, but they don't work how I want. The problem is, that part of site is static text ( not in database ) , other part ( products ) are in MySQL database - this part is generating from PHP scripts. Ben Edwards [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] This kind of depends on what database you are using (I am asuming you mean you have a data driven site you want to search so strictly speaking it is the database that you want to search). Mysl has free text search facilities (i.e. you can pass it a number of words and it can search for them in a set of database fields and even kreates a 'ranking'). however this only works if you have a few hundread records - less than this and the results are unpredictable. Have you tries googeling for php search scripts? Ben On Thu, 20 Jan 2005 14:04:44 +0200, Rosen [EMAIL PROTECTED] wrote: Hi, Can someone recommend me a search engine script in PHP for inside one site? Thanks in advance! Rosen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Ben Edwards - Poole, UK, England WARNING:This email contained partisan views - dont ever accuse me of using the veneer of objectivity If you have a problem emailing me use http://www.gurtlush.org.uk/profiles.php?uid=4 (email address this email is sent from may be defunct) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Ben Edwards - Poole, UK, England WARNING:This email contained partisan views - dont ever accuse me of using the veneer of objectivity If you have a problem emailing me use http://www.gurtlush.org.uk/profiles.php?uid=4 (email address this email is sent from may be defunct) -- Robert Sossomon, Business and Technology Application Technician 4-H Youth Development Department 200 Ricks Hall, Campus Box 7606 N.C. State University Raleigh NC 27695-7606 Phone: 919/515-8474 Fax: 919/515-7812 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php ___ Sent by ePrompter, the premier email notification software. Free download at http://www.ePrompter.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Search engine
On Thu, 20 Jan 2005 14:04:44 +0200, Rosen [EMAIL PROTECTED] wrote: Can someone recommend me a search engine script in PHP for inside one site? Use HTDig. Here's a tutorial on how to use it and how to write a PHP wrapper around the result set for total customization of the display results: http://www.devshed.com/c/a/PHP/Search-This/ -- Greg Donald Zend Certified Engineer http://destiney.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Search indexing.. Re: [PHP] Search engine
On Thu, 20 Jan 2005 8:16:28 -0500, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Just out of curiosity.. relating to this subject.. does anyone have any good documentation on creating your own site index so you can create your own search engine? http://www.devshed.com/c/a/PHP/Search-This/ -- Greg Donald Zend Certified Engineer http://destiney.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Search Engine Friendly URLs
On Fri, 14 Jan 2005 13:46:54 -0500, Josh [EMAIL PROTECTED] wrote: I am converting a site to use includes instead of a Dreamweaver template. I want the URLs to look like this: www.my-site1234.com/contact instead of www.my-site1234.com/default.php?p=contact. I found some tutorials on editing the .htaccess file but where do I find it on the server? The .htaccess file is created in the web directory where your .php files are. It affects all directories from there down. Looks like you may want something like this: RewriteEngine on RewriteRule ^([A-Za-z].*) default.php?p=$1 [L,qsappend] You might also want RewriteRule ^$ default.php?p=index [L,qsappend] for a catch-all bounce to the homepage. http://httpd.apache.org/docs/mod/mod_rewrite.html -- Greg Donald Zend Certified Engineer http://destiney.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Search Engine Friendly URLs
On Fri, 2005-01-14 at 13:46 -0500, Josh wrote: I am converting a site to use includes instead of a Dreamweaver template. I want the URLs to look like this: www.my-site1234.com/contact instead of www.my-site1234.com/default.php?p=contact. I found some tutorials on editing the .htaccess file but where do I find it on the server? You need to create the file in the root directory of your website. Example: if your website is located in /home/web/foo/public_html/ then you need to create the file: /home/web/foo/public_html/.htaccess You also need to make some adjustments to Apache to allow you to do this. -Robby -- /*** * Robby Russell | Owner.Developer.Geek * PLANET ARGON | www.planetargon.com * Portland, OR | [EMAIL PROTECTED] * 503.351.4730 | blog.planetargon.com * PHP/PostgreSQL Hosting Development *--- Now supporting PHP5 --- / -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Search engine : build a new one or use an alreadry existing one ?
On Sun, 7 Nov 2004 19:10:32 -0400, robert mena [EMAIL PROTECTED] wrote: I need to improve my current search mecanism but got stuck in a dilema : build one or use an existing engine? I recently put together a large company intranet site search using htdig and a simple php wrapper script: http://www.devshed.com/c/a/PHP/Search-This/ http://www.htdig.org/ This setup allows me a great deal of graphical customization in the results display while putting all the real work with search results and search logic on htdig. -- Greg Donald Zend Certified Engineer http://gdconsultants.com/ http://destiney.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Search engine : build a new one or use an alreadry existing one ?
Greg Donald wrote: I need to improve my current search mecanism but got stuck in a dilema : build one or use an existing engine? I recently put together a large company intranet site search using htdig and a simple php wrapper script: http://www.devshed.com/c/a/PHP/Search-This/ http://www.htdig.org/ I've used the Zoom search engine by Wrensoft http://www.wrensoft.com/zoom/ with PHP on a Windows system, and it worked well. Also, I've never used it, but I've heard that mnoGoSearch works, well, too. -- Ben Ramsey Zend Certified Engineer http://benramsey.com --- Atlanta PHP - http://www.atlphp.org/ The Southeast's premier PHP community. --- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Search engine : build a new one or use an alreadry existing one ?
* Thus wrote robert mena: Hi, I need to improve my current search mecanism but got stuck in a dilema : build one or use an existing engine? My site, that uses php/smarty allows my users to browse products in a category listing or search. Currently my search only performs a 'select xxx from where field like ' and show the results. Even tough it works I'd like to improve it, showing the results by relevance, proper hadling mispelled words, performing the serach not only in the product's name etc. If your using mysql, look at the match()/full text index functionality it provides. This can be a usesfull feature. Curt -- Quoth the Raven, Nevermore. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Search engine : build a new one or use an alreadry existing one ?
Curt Zirzow wrote: * Thus wrote robert mena: Hi, I need to improve my current search mecanism but got stuck in a dilema : build one or use an existing engine? My site, that uses php/smarty allows my users to browse products in a category listing or search. Currently my search only performs a 'select xxx from where field like ' and show the results. Even tough it works I'd like to improve it, showing the results by relevance, proper hadling mispelled words, performing the serach not only in the product's name etc. If your using mysql, look at the match()/full text index functionality it provides. This can be a usesfull feature. Curt If you have access to install things on your server I would consider using Swish-E, i'm using it on www.question.com and it's working great, and it has a php interface. http://www.swish-e.org/ Nick -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Search engine : build a new one or use an alreadry existing one ?
Hi Can I use them (swish-e HtDig) for unicode scripts? Sadeq On Mon, 08 Nov 2004 13:49:32 +1300, Noodles [EMAIL PROTECTED] wrote: Curt Zirzow wrote: * Thus wrote robert mena: Hi, I need to improve my current search mecanism but got stuck in a dilema : build one or use an existing engine? My site, that uses php/smarty allows my users to browse products in a category listing or search. Currently my search only performs a 'select xxx from where field like ' and show the results. Even tough it works I'd like to improve it, showing the results by relevance, proper hadling mispelled words, performing the serach not only in the product's name etc. If your using mysql, look at the match()/full text index functionality it provides. This can be a usesfull feature. Curt If you have access to install things on your server I would consider using Swish-E, i'm using it on www.question.com and it's working great, and it has a php interface. http://www.swish-e.org/ Nick -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- - Yazd, 8917954894 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Search engine : build a new one or use an alreadry existing one ?
I believe swish-e does Unicode, but I'm not 100% sure Nick -Original Message- From: Sadeq Naqashzade [mailto:[EMAIL PROTECTED] Sent: Monday, 8 November 2004 2:57 p.m. To: Noodles Cc: [EMAIL PROTECTED] Subject: Re: [PHP] Search engine : build a new one or use an alreadry existing one ? Hi Can I use them (swish-e HtDig) for unicode scripts? Sadeq On Mon, 08 Nov 2004 13:49:32 +1300, Noodles [EMAIL PROTECTED] wrote: Curt Zirzow wrote: * Thus wrote robert mena: Hi, I need to improve my current search mecanism but got stuck in a dilema : build one or use an existing engine? My site, that uses php/smarty allows my users to browse products in a category listing or search. Currently my search only performs a 'select xxx from where field like ' and show the results. Even tough it works I'd like to improve it, showing the results by relevance, proper hadling mispelled words, performing the serach not only in the product's name etc. If your using mysql, look at the match()/full text index functionality it provides. This can be a usesfull feature. Curt If you have access to install things on your server I would consider using Swish-E, i'm using it on www.question.com and it's working great, and it has a php interface. http://www.swish-e.org/ Nick -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- - Yazd, 8917954894 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Search a word in multiple tables
Hi, How can i search a specific word in 2 tables I use this but it is not working sql = SELECT a.product_id, a..select_language('product_name_en', 'product_name_fr')., b.brand_name FROM products_accessories as a, brands as b WHERE (a..select_language('product_name_en', 'product_name_fr'). LIKE '%.$word.%' OR b.brand_name LIKE '%.$word.%'); $result= mysql_query($sql); Are you using MySQL? If so, depending on which version you have, it might be worth checking out UNION queries. http://dev.mysql.com/doc/mysql/en/UNION.html Much warmth, Murray http://www.planetthoughtful.org Building a thoughtful planet, One quirky comment at a time. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Search a word in multiple tables
Phpu wrote: Hi, How can i search a specific word in 2 tables I use this but it is not working sql = SELECT a.product_id, a..select_language('product_name_en', 'product_name_fr')., b.brand_name FROM products_accessories as a, brands as b WHERE (a..select_language('product_name_en', 'product_name_fr'). LIKE '%.$word.%' OR b.brand_name LIKE '%.$word.%'); $result= mysql_query($sql); Thanks does this become a PHP question just because of $result= mysql_query($sql); ?? -- Raditha Dissanayake. http://www.radinks.com/sftp/ | http://www.raditha.com/megaupload Lean and mean Secure FTP applet with | Mega Upload - PHP file uploader Graphical User Inteface. Just 128 KB | with progress bar. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] search string / query format
Ed Lazor wrote: I'm going to create a search page that accepts input similar to places like Yahoo and Google. [snip] Also, I've heard that MySQL's indexing can support some of this, but I'm not sure how much. Using a FULLTEXT index and searching in BOOLEAN mode supports the type of search strings that you wrote. Consult thine manual!! (The MySQL one) ;) -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals www.phparch.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] search string / query format
Keyword AND keyword2 keyword keyword2 -keyword3 It doesn't support AND or OR but it does use - + * and others. Consult thine manual!! (The MySQL one) ;) http://dev.mysql.com/doc/mysql/en/Fulltext_Search.html The problem is getting a FULLTEXT to sort by relevancy. This was a real pain, until our friend John W. showed me the error of my ways; (see below). MySQL The preceding example is a basic illustration showing how to use the MATCH() function MySQL where rows are returned in order of decreasing relevance I never did believe the examples helped me: http://dev.mysql.com/doc/mysql/en/Fulltext_Search.html You will need something like this to make the operators display according to relevancy. This works: SELECT *,MATCH (field1,field2,field3) AGAINST ('Margaret Atwood' IN BOOLEAN MODE) AS relevancy FROM mytable WHERE MATCH (field1,field2,field3) AGAINST ('Margaret Atwood' IN BOOLEAN MODE) ORDER BY relevancy DESC; This does not sort by relevancy well at all: SELECT * (field1,field2,field3) FROM mytable AGAINST ('Margaret Atwood' IN BOOLEAN MODE); P.S. John W.: thanks for helping me on my post last week. I finally got this working. John John W. Holmes wrote: Ed Lazor wrote: I'm going to create a search page that accepts input similar to places like Yahoo and Google. [snip] Also, I've heard that MySQL's indexing can support some of this, but I'm not sure how much. Using a FULLTEXT index and searching in BOOLEAN mode supports the type of search strings that you wrote. Consult thine manual!! (The MySQL one) ;) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] search string / query format
-Original Message- I'm going to create a search page that accepts input similar to places like Yahoo and Google. [snip] Also, I've heard that MySQL's indexing can support some of this, but I'm not sure how much. Using a FULLTEXT index and searching in BOOLEAN mode supports the type of search strings that you wrote. Consult thine manual!! (The MySQL one) ;) *grin* Thanks John, I knew someone would know where I'd seen it hehe -Ed -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php