jedzf Posted September 10, 2011 Share Posted September 10, 2011 the interface explains everything #page1.html <html> <head> </head> <body> <table border='0' width='50%' cellspacing='0' cellpadding='0' > <form name=form1 method=post action="page2.php"> <?PHP $postData[] = array(); $postData[0] = '9'; $postData[1] = '8'; $postData[2] = '7'; $postData[3] = '6'; ?> <tr> <td><b>Choose your order</b></td> <td> </td> <td> <input type=checkbox name=scripts[] value='<?PHP $postData[0]; ?>'>pasta <br> <input type=checkbox name=scripts[] value='<?PHP $postData[1]; ?>'>burger <br> <input type=checkbox name=scripts[] value='<?PHP $postData[2]; ?>'>fries <br> <input type=checkbox name=scripts[] value='<?PHP $postData[3]; ?>'>chili dog <br> <br> </td> </tr> <tr><td align=center > <input type=submit value=Submit> <input type=reset value=Reset></td></tr> </form> </table> </body> </html> #page2.php <?PHP if ($_SERVER['REQUEST_METHOD'] == 'POST') { if (isset($_POST['scripts'])) { $cb = $_POST['scripts']; $numRows = count($cb); print "you have chosen the following order numbers:"; for($i=0; $i<$numRows; $i++){ print $cb[$i] . "<br>"; } } else{ print "you have'nt checked anything!"; } } ?> What do? :'( Quote Link to comment https://forums.phpfreaks.com/topic/246833-my-order-wont-show-array-problem/ Share on other sites More sharing options...
redarrow Posted September 10, 2011 Share Posted September 10, 2011 sorry, but what are you trying to do. Quote Link to comment https://forums.phpfreaks.com/topic/246833-my-order-wont-show-array-problem/#findComment-1267606 Share on other sites More sharing options...
jedzf Posted September 10, 2011 Author Share Posted September 10, 2011 im tryin to display the order no. to the other page, which is related to what the user checked. it will display some numbers. for example: "you have chosen the following order numbers:" "9" "6" this will be printed if i choose to check pasta and burger Quote Link to comment https://forums.phpfreaks.com/topic/246833-my-order-wont-show-array-problem/#findComment-1267617 Share on other sites More sharing options...
Pikachu2000 Posted September 10, 2011 Share Posted September 10, 2011 This won't do anything without using echo. If you had looked at the html source, you'd have seen that none of the checkboxes have anything in their value= attributes. <input type=checkbox name=scripts[] value='<?PHP $postData[0]; ?>'>pasta <br> Quote Link to comment https://forums.phpfreaks.com/topic/246833-my-order-wont-show-array-problem/#findComment-1267666 Share on other sites More sharing options...
redarrow Posted September 10, 2011 Share Posted September 10, 2011 I was playing around, and fort this might help you, in your progress. it only a rough example of making a order at a cafe. can be well extended. <?php session_start(); $order_id=rand(11111,5); $_SESSION['order_id']=$order_id; if($_POST['submit']){ echo "<b>MY LIITLE CAFE!</b> <br><br>"; $burger=$_POST['burger']; echo "Order id: ".$_SESSION['order_id']." <br><br>"; echo "Order information <br><br>"; foreach($burger as $burger){ if("checked"){ switch($burger){ case "burger1": echo" $burger \n image 1 <br>"; break; case "burger2": echo" $burger \n image 2 <br>"; break; case "burger3": echo" $burger \n image 3 <br>"; break; case "burger4": echo" $burger \n image 4"; break; } } } echo" <br><br><A HREF='javascript:history.go(-1)'>[Re order]</A>"; exit; } echo"<p><p>"; ?> <form method="post"> <img src="" /> <input type="checkbox" name="burger[]" value="burger1" checked="checked" /> <img src=""/> <input type="checkbox" name="burger[]" value="burger2" checked="checked"/> <img src=""/> <input type="checkbox" name="burger[]" value="burger3" checked="checked" /> <img src=""/> <input type="checkbox" name="burger[]" value="burger4" checked="checked" /> <br /><br /> <input type="submit" name="submit"> </form> Quote Link to comment https://forums.phpfreaks.com/topic/246833-my-order-wont-show-array-problem/#findComment-1267676 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.