Karyna Posted October 12, 2012 Share Posted October 12, 2012 hi all i have a problem i guess my code is right but i dont know what im doing wrong pls helpp i have one page lets say comiditis.php <form id="form1" name="form1" method="post" action="comoditi2.php"> bla, bla, bla $totalRows_Recordset1 = mysql_num_rows($Recordset1); $comodi=$row_Recordset1['nm']; $arr = explode(",", $comodi); $i=0; foreach ($arr as &$value) { //$value = $value * 2; // echo $arr[$i]."<br />\n"; $aidi=$arr[$i]; ?> <label> <input name="comoditis" type="checkbox" id="<?php echo $i;?> " value="check" /> <?php echo $aidi; ?> </label> <?php $i++; } ?> *********************************************************** comiditi2.php <?php // $ai=$_POST['comoditis']; <<<---- heres my problem!!! // echo $ai; ?> HOW I KNOW WHAT CHECKBOXES ARE CHECKED??? i cant even print the values of the array??? whatv im doing wrong?? tnx in advance Quote Link to comment https://forums.phpfreaks.com/topic/269405-post-array-values/ Share on other sites More sharing options...
Jessica Posted October 12, 2012 Share Posted October 12, 2012 Change <input name="comoditis" to <input name="comoditis[]". Change the value to 1, not a string. On your processing page, do a print_r($_POST); and you can see what's been posted. $_POST['comoditis'] will be an array of all the checked boxes. Quote Link to comment https://forums.phpfreaks.com/topic/269405-post-array-values/#findComment-1384883 Share on other sites More sharing options...
Barand Posted October 13, 2012 Share Posted October 13, 2012 Seems to me there needs to be the value $i in there somewhere. Either name = 'comoditis[$i]' value='1' or name = 'comoditis[]' value='$i' Either way you should not be exploding fields from within a database. The individual values should be in separate rows. Quote Link to comment https://forums.phpfreaks.com/topic/269405-post-array-values/#findComment-1385029 Share on other sites More sharing options...
ManiacDan Posted October 14, 2012 Share Posted October 14, 2012 Either way you should not be exploding fields from within a database. The individual values should be in separate rows. We're starting this again already? Quote Link to comment https://forums.phpfreaks.com/topic/269405-post-array-values/#findComment-1385063 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.