Presto-X Posted February 6, 2009 Share Posted February 6, 2009 Hey guys I could really use your help in a bad way... I created a basic order form with a list of checkboxes and textfields for quantity, the form looks something like this: [checkbox] Product Name 1 [textfield for quantity] [checkbox] Product Name 2 [textfield for quantity] [checkbox] Product Name 3 [textfield for quantity] You can view the page here: http://www.sierrarescue.com/index.php?option=com_instructors&step=1 This is the code that I'm using to create the form loop on the product page: <?PHP while ($products = mysql_fetch_object($products_sql)){ ?> <tr> <td width="25"><input type="checkbox" name="price" id="checkbox<?php echo $products->id; ?>" value="<?php echo $products->price; ?>" /></td> <td><label for="checkbox<?php echo $products->id; ?>"><?php echo $products->name; ?></label></td> <td width="65" nowrap="nowrap">$<span id="price<?php echo $products->id; ?>"><?php echo $products->price; ?></span> </td> <td width="20"><input name="id<?php echo $products->id; ?>" id="quantity<?php echo $products->id; ?>" type="text" size="3" value="0" onFocus="if(this.value=='0'){this.value=''};" onBlur="if(this.value==''){this.value='0'};" /></td> </tr> <?PHP } ?> Now for my problem, I am not sure the best way to get this data on the next page, I have been trying to use foreach($_POST as $name => $value){ $name1 = str_replace("_"," ",$name); $nameSTR = substr($name1,0,; if($name=="totalcost"){$totalcost=$value;} if($nameSTR=="quantity"){$quantity=$value;} if(($nameSTR=="subtotal")or($nameSTR=="shipping")or($nameSTR=="quantity")or($nameSTR=="submit")or($name=="totalcost")){ # If the fields name string = subtotal, shipping or quantity Do Nothing and move on... }else{ print "<tr><td nowrap=\"nowrap\" class=\"productName\">$name1</td><td width=\"18%\" align=\"right\" class=\"productName\">$$value $quantity</td></tr>"; } } with out any luck it is not working as I tought it would, it's doing a new row for each posted item and I want it to display the product name, price and quantity all on one line. Link to comment https://forums.phpfreaks.com/topic/144129-im-trying-to-use-foreach-with-post-with-out-any-luck-please-help-if-you-can/ Share on other sites More sharing options...
frost Posted February 6, 2009 Share Posted February 6, 2009 try this one the post page, it might help you debug: foreach($_POST as $key=>$value){ echo "$key :: $value <BR>"; } Link to comment https://forums.phpfreaks.com/topic/144129-im-trying-to-use-foreach-with-post-with-out-any-luck-please-help-if-you-can/#findComment-756275 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.