dennismonsewicz Posted September 30, 2008 Share Posted September 30, 2008 Here is the code: <?php include "includes/sql.php"; $action = $_GET['action']; switch($action) { case "foreach": echo '<form action="foreach.php?action=results" method="post">'; echo '<div><input type="checkbox" name="checkboxes[pm1]" class="checkbox" id="pm1" value="1" /> <label for="pm1">PM</label></div>'; echo '<div><input type="checkbox" name="checkboxes[designer1]" class="checkbox" id="designer1" value="1" /> <label for="designer1">Designer</label></div>'; echo '<div><input type="checkbox" name="checkboxes[pm2]" class="checkbox" id="pm2" value="1" /> <label for="pm2">PM</label></div>'; echo '<div><input type="checkbox" name="checkboxes[writer]" class="checkbox" id="writer" value="1" /> <label for="writer">Writer</label></div>'; echo '<div><input type="checkbox" name="checkboxes[pm3]" class="checkbox" id="pm3" value="1" /> <label for="pm3">PM</label></div>'; echo '<div><input type="checkbox" name="checkboxes[designer2]" class="checkbox" id="designer2" value="1" /> <label for="designer2">Designer</label></div>'; echo '<div><input type="checkbox" name="checkboxes[pm4]" class="checkbox" id="pm4" value="1" /> <label for="pm4">PM</label></div>'; echo '<div><input type="checkbox" name="checkboxes[christine]" class="checkbox" id="christine" value="1" /> <label for="christine">Christine</label></div>'; echo '<div><input type="checkbox" name="checkboxes[pm5]" class="checkbox" id="pm5" value="1" /> <label for="pm5">PM</label></div>'; echo '<div><input type="checkbox" name="checkboxes[designer3]" class="checkbox" id="designer3" value="1" /> <label for="designer3">Designer</label></div>'; echo '<div><input type="checkbox" name="checkboxes[pm6]" class="checkbox" id="pm6" value="1" /> <label for="pm6">PM</label></div>'; echo '<div><input type="checkbox" name="checkboxes[julie]" class="checkbox" id="julie" value="1" /> <label for="julie">Julie</label></div>'; echo '<div><input type="checkbox" name="checkboxes[pm7]" class="checkbox" id="pm7" value="1" /> <label for="pm7">PM</label></div>'; echo '<div><input type="checkbox" name="checkboxes[designer4]" class="checkbox" id="designer4" value="1" /> <label for="designer4">Designer</label></div>'; echo '<div><input type="checkbox" name="checkboxes[pm8]" class="checkbox" id="pm8" value="1" /> <label for="pm8">PM</label></div>'; echo '<div><input type="checkbox" name="checkboxes[proofreading]" class="checkbox" id="proofreading" value="1" /> <label for="proofreading">Proofreading</label></div>'; echo '<div><input type="checkbox" name="checkboxes[pm9]" class="checkbox" id="pm9" value="1" /> <label for="pm9">PM</label></div>'; echo '<div><input type="checkbox" name="checkboxes[layne]" class="checkbox" id="layne" value="1" /> <label for="layne">Layne</label></div>'; echo '<div><input type="checkbox" name="checkboxes[pm10]" class="checkbox" id="pm10" value="1" /> <label for="pm10">PM</label></div>'; echo '<div><input type="checkbox" name="checkboxes[programming]" class="checkbox" id="programming" value="1" /> <label for="programming">Programming</label></div>'; echo '<div><input type="checkbox" name="checkboxes[pm11]" class="checkbox" id="pm11" value="1" /> <label for="pm11">PM</label></div>'; echo '<div><input type="checkbox" name="checkboxes[testing]" class="checkbox" id="testing" value="1" /> <label for="testing">Testing</label></div>'; echo '<input type="submit" value="Submit" />'; echo '</form>'; break; case "results": foreach($_POST['checkboxes'] as $key=>$val) { $qry = mysql_query("INSERT INTO fake ($key) VALUES ($val)") or die(mysql_query()); if($qry) { echo "Check: $key, Value: $val <br />"; } } break; } ?> Ok when I run the code it inserts each check into its own individual row instead of the same row... any help? Quote Link to comment Share on other sites More sharing options...
Barand Posted September 30, 2008 Share Posted September 30, 2008 That's because divs are block elements and force a new line unless given a float style. But this is a CSS/HTML issue, not PHP. Moved. Quote Link to comment 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.