[SOLVED] Search All Can't seem to be able to set this up

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Addos
Forum Contributor
Posts: 305
Joined: Mon Jan 17, 2005 4:13 pm

Post by Addos »

Hi,
You are very patient with me.

I have added this also but the echo returns:
locations.counties_IDPK = \'%\'

Again I have made this change to the site at:
http://www.irishmusicteachers.ie/index_test.php

This is also the code for the select box with the changes you suggest:

Code: Select all

<?PHP echo "<select name='Counties_IDPK' id='Counties_IDPK'>\n
	   <option value=\"'%'\">Search All</option>"; 
	while($dbRow = mysql_fetch_array($rstSearchLocations)){ 
  		echo "<option value='"
		. $dbRow["Counties_IDPK"]  
		. "'>"
		. $dbRow["Counties_Name"]
		."</option>\n"; 
		} echo "</select>\n"; 
		?>
      Choose County
Thanks again
B :wink:
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

Code: Select all

<?PHP echo "<select name=\"Counties_IDPK\" id=\"Counties_IDPK\">\n
	   <option value=\"'%'\">Search All</option>"; 
	while($dbRow = mysql_fetch_array($rstSearchLocations)){ 
  		echo "<option value='"
		. $dbRow["Counties_IDPK"]  
		. "'>"
		. $dbRow["Counties_Name"]
		."</option>\n"; 
		} echo "</select>\n"; 
		?>
      Choose County
try that...
Addos
Forum Contributor
Posts: 305
Joined: Mon Jan 17, 2005 4:13 pm

Post by Addos »

Sorry exact same result :cry:
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

ok, tried it with something similar I just did and correct you are, same result:

stripslashes() you need around the $_POST var.
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

Code: Select all

if  ($_POST['Counties_IDPK']) {  $query_rstResults .= ' AND locations.counties_IDPK like ' . stripslashes($_POST['Counties_IDPK']);  }
sorry for the double post I am, wanted to be sure he got the addition I did...
Addos
Forum Contributor
Posts: 305
Joined: Mon Jan 17, 2005 4:13 pm

Post by Addos »

Ok I have tried adding stripslashes() but the result is showing:

Code: Select all

locations.counties_IDPK = like '%'
Again you can see for yourself. http://www.irishmusicteachers.ie/index_test.php

I did try removing the word ‘like’ and then got the following which didn’t contain an error but didn’t return all the data in the database for this part of the ‘Search All’

Code: Select all

SELECT * FROM teachers,inst_teach,locations,instruments WHERE teachers.contents_IDPK = inst_teach.teacher_IDFK AND inst_teach.instrument_IDFK = instruments.instruments_IDPK AND teachers.counties_IDFK = locations.counties_IDPK AND locations.counties_IDPK = '%' AND instruments.instruments_IDPK = 65 ORDER BY teachers.contents_IDPK
Thanks a mil and sorry to be such a bother.
B
Addos
Forum Contributor
Posts: 305
Joined: Mon Jan 17, 2005 4:13 pm

Post by Addos »

Ok I hope I caught you in time. The problem is solved. I had to replace the " with ' that I origionally had removed in the test a few posts back e.g. "Counties_IDPK\" is now 'Counties_IDPK\' again and all seems to be working ok.

If you go to the same page now and 'Select All' and Select 'Guitar' all the entries in the database are now returned.

Thanks you very much for this invaluable help. It has been a good lesson and one that I have learned a lot from.

Thanks again

Brian :wink:
Post Reply