I have a search results page I want to send URL var to. So if someone is looking for a tshirt with a color they can select red, blue and green and get a list of shirts with colors red, blue and green. I did search_results.php?color=red&blue&green just gets me the the red shirts. How do I send this URL var so I can get all the colors to be pulled from the database?
Thanks.
You probably want to use another separator, or at least urlencode it, e.g.,
echo '<a href="search_results.php?color="' . urlencode('red&blue&green') . '">search results</a>';
Thanks Laser,
Didnt work for me. I think I may ave to re-write the search function to take each color and query the database with AND. I think LOL. thanks for the help.
ramell2 wrote:Didnt work for me.
Didnt work for me.
How did it not work?
The principle is correct. If it did not work, then the fault is with the implementation, e.g., you forgot to use [man]explode/man on the receiving page to obtain the individual colour names.
I keep getting all the shirts with the first color. Ill check the explode(). Ive looked all over for a salutation thanks for the help.
No problem. By the way:
ramell2 wrote:I think I may ave to re-write the search function to take each color and query the database with AND.
I think I may ave to re-write the search function to take each color and query the database with AND.
You should use IN instead.
Use the encode_array in the discussed in the manual http://php.net/manual/en/function.urlencode.php to help you understand arrays in get requests. You then have access to an array with the selected colors in code.
Thanks Tom,
Ill give it a try
Hey Guys thanks for your help. I used an IN() and passed the var into it. Works great.