Forum Moderators: coopster
I have a form with multiple checkboxes that a user can choose from, to compare products. The form sends the input as parameters (GET) to the following pages URL. On that following page I have separate queries for each parameter, that pulls up the relevant data for that product. Users should choose a max of 4 products to compare. So far so good, when the user chooses 4 products, the page loads as expected.
My issue is that if a user only chooses 2 or 3 products, I get an error message on the following page, basically because the query and the resulting data being shown can't work, as 1 parameter is missing from the URL.
My questions:
Can I define that the form goes to a different page, depending on the amount of checkboxes chosen, e.g. 2 products goes to Compare2.php, 3 goes to Compare3.php etc?
Or should I somehow change the results page? If so, where would I need to start?
Thanks, Adam
Try to mod the results page yourself, but if you get stuck post some of the relevant code and we can see where we can get it.
good luck
I already have the parameters in an array ($ID[]) and can use them accordingly. As I mentioned, there are sql queries on the following page as such:
mysql_select_db($database_BBAddict, $BBAddict);
$query_rsMod0 = "SELECT * FROM bb_data WHERE id = $ID[0]";
$rsMod0 = mysql_query($query_rsMod0, $BBAddict) or die(mysql_error());
$row_rsMod0 = mysql_fetch_assoc($rsMod0);
$totalRows_rsMod0 = mysql_num_rows($rsMod0);
This is obviously repeated 4 times (1 for each parameter). Each of these sql queries feeds a column in the table where the products can be compared. I have searched around for possibilities on how I could do this on one page, but the only possibility I have come up with is an if / else loop on each data point in the table for the 3rd and 4th parameter. This would make the page heavy loading though, as each product has around 75 data points...
This is what you have:
$query_rsMod0 = "SELECT * FROM bb_data WHERE id = $ID[0]";
With a little check up for empitness:
if ($ID[0] <> "") {
$where_cond = "id = $ID[0] OR";
}else if ($ID[0] <> "") {
$where_cond .= "id = $ID[1] OR";
}else if ($ID[0] <> "") {
$where_cond .= "id = $ID[2] OR";
}else if ($ID[0] <> "") {
$where_cond .= "id = $ID[3]";
}
you can construct the query:
$query_rsMod0 = "SELECT * FROM bb_data WHERE ". $where_cond;
Habtom
The table (in HTML) looks like this:
-----------------Prod1---Prod2---Prod3---Prod4
Feature1-----------X-------0-------0-------X
Feature2-----------X-------0-------0-------X
Feature3-----------X-------0-------0-------X
Feature4-----------0-------0-------0-------X
Feature5-----------X-------0-------X-------0
etc...