Get ready for BLACK FRIDAY shopping starting in

Forums

PHP

This topic is locked

parameters from form defining reordsets on result

Posted 01 Sep 2007 20:13:05
1
has voted
01 Sep 2007 20:13:05 adam homfray posted:
hey folks, I seem to have put myslef in a position that I cant get myself out of <img src=../images/dmxzone/forum/icon_smile.gif border=0 align=middle>

Using DW8, php and mysql...

I have a form with multiple checkboxes, users can choose between 2 and 4 products, which are sent to the results page, where they can compare the products. The parameters are in an array ($ID[]) on the resulting page, and I have individual recordsets as such (to pull up the relevant data for those products):

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 RS is repeated for each parameter, and they work fine. The page works fine when 4 products are chosen, the results page shows all 4 products with all functionality. My issue is that when a user chooses 2 or 3 products, I get an error, because the recordset for the missing parameters can't function correctly (obviously).

So, my question is, how can I ignore the 4th RS if only 3 products are chosen, or ignore the 3rd and 4th if only two are chosen? 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...

I'd appreciate any help, Adam

Reply to this topic