Forums
This topic is locked
RecordSet from multiple parameters in URL
Posted 10 Aug 2007 22:37:07
1
has voted
10 Aug 2007 22:37:07 adam homfray posted:
Hey folks, I'm new here, looking for some DW help <img src=../images/dmxzone/forum/icon_smile.gif border=0 align=middle>Ive been using DW for a while, and recently ventured into PHP/MySQL, and the world of recordsets. What I am trying to do is create a comparison site for certain products, and where I'm stuck is with a recordset based on more than one parameter from the URL. heres the details:
On index.php I have a set of 14 checkboxes that send variables (FuncIDx). These refer to a functionality that a product may or may not have, which define what should be seen on the next page. When a user chooses one or more of the check boxes and clicks go, the parameters are sent to the following page as such: MultiFunc.php?FuncID%5B%5D=FuncID05&FuncID%5B%5D=FuncID11&FuncID%5B%5D=FuncID44&submit=Go
Although this isnt pretty, its correct, the user chose three functionalities (FuncID's), 05, 11 and 44, which in turn refers to Camera, GPS and microSD card.
Ehat this page should be doing is listing products that have these functionalities. In a separate table where the product details are stored, there are columns named after each and every FuncID. Ideally, I want to show the following:
There are two products which have: Camera, GPS and microSD card: Product 1, Product 2
What I have already worked out is how to show what was filtered for on that page using str_replace in the array. When the user reaches that page, he sees: You filtered for Camera, GPS and microSD card. What I cant work out is how to call up the products based on those selections.
I would appreciate any pointers in the right direction <img src=../images/dmxzone/forum/icon_smile.gif border=0 align=middle>
Thanks, Adam
Edited by - oxide-tones on 11 Aug 2007 05:55:04
Replies
Replied 14 Aug 2007 00:57:30
14 Aug 2007 00:57:30 Alan C replied:
Sounds like what you will need is a query that is built up in stages so that it looks for the appropriate products, you could do this with a function in php, I did something similar when there was a query that needed to look for a whole lot of criteria but they were not known until the user specified them, here's the function I wrote to build the query. The two parameters are the existing query, which can be a blank string, and the new criteria to add, the function inserts WHERE if needed then adds the required clauses, you still have to generate the first part of the query yourself.
<pre id=code><font face=courier size=2 id=code> # used to build a WHERE clause in archive_select, adds more criteria
# always checks whether WHERE has already been added
function buildWhere($where_string, $addition)
{
if (!strpos($where_string, 'WHERE'))
{
$where_string =' WHERE ';
}
else
{
$where_string.=' AND ';
}
return $where_string.$addition;
}</font id=code></pre id=code>
<pre id=code><font face=courier size=2 id=code> # used to build a WHERE clause in archive_select, adds more criteria
# always checks whether WHERE has already been added
function buildWhere($where_string, $addition)
{
if (!strpos($where_string, 'WHERE'))
{
$where_string =' WHERE ';
}
else
{
$where_string.=' AND ';
}
return $where_string.$addition;
}</font id=code></pre id=code>