PHP - Moved: Check Box Checked Along
This topic has been moved to JavaScript Help.
http://www.phpfreaks.com/forums/index.php?topic=318750.0 Similar TutorialsI am new to PHP and learning as I go I am stuck with a piece of code that I am trying to change. I have a php application that has tickboxes in and some are checked as standard. I want to change the tick box setting to be unchecked as standard. Here is the code. <label><input type="checkbox" name="notify" value="1" <?php echo (!isset($_SESSION['as_notify']) || !empty($_SESSION['as_notify'])) ? 'checked="checked"' : ''; ?> /> <?php echo $hesklang['seno']; ?></label><br /> I have tried everything I know but since I do not know that much I have been unable to change the standard. I am sure it is something small that I am overlooking. Anyone out there know what I am doing wrong? This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=358408.0 This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=349419.0 This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=349419.0 I've been trying to simplify this code, let alone make it work. It's a loop to change the different question checkboxes to "checked" if certain degree_ids are found. All of the examples i have looked at are very strange and I'm not sure how to go about this, thought it seems to be a common question. Everyone seems to have their own way. Any advice would be greatly appreciated. for($i =1; $i <= $arraycount; $i++){ $query = "SELECT degree_id FROM `user-degree` WHERE `user_id` = '".$user_id."' AND degree_id = '".$i."'"; $result = $conn->query($query) or die(mysql_error()); $row = mysqli_fetch_array($result) ; echo $row['degree_id']; if(!$y){ $y = 0; } if ($row['degree_id'] == 1){ $q4[0] = 'checked'; } if ($row['degree_id'] == 2){ $q4[1] = 'checked'; } if ($row['degree_id'] == 3){ $q4[2] = 'checked'; } if ($row['degree_id'] == 4){ $q4[3] = 'checked'; } if ($row['degree_id'] == 5){ $q4[4] = 'checked'; } if ($row['degree_id'] == 6){ $q4[5] = 'checked'; } if ($row['degree_id'] == 7){ $q4[6] = 'checked'; } if ($row['degree_id'] == 8){ $q4[7] = 'checked'; } if ($row['degree_id'] == 9){ $q4[8] = 'checked'; } } This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=317810.0 This topic has been moved to Ajax Help. http://www.phpfreaks.com/forums/index.php?topic=313543.0 This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=306339.0 This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=320394.0 This topic has been moved to Application Design. http://www.phpfreaks.com/forums/index.php?topic=347295.0 This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=313299.0 This topic has been moved to Other Libraries and Frameworks. http://www.phpfreaks.com/forums/index.php?topic=306254.0 This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=311729.0 This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=331164.0 This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=327134.0 This topic has been moved to PHP Installation & Configuration. http://www.phpfreaks.com/forums/index.php?topic=326567.0 This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=347719.0 Hello all, The following script is used to query an array. (www.example.com/test.php?lev[]=MS&lev[]=College) Currently, it echos the values queried and simply lists them (echo "$lev (br />\n"). Is it possible to echo those values by keeping the checkbox in question checked instead? Code: [Select] <?php echo "<b>Levels <br /> />"; if(!empty($_GET['lev'])) foreach($_GET['lev'] as $lev){ echo "$lev <br />\n"; } ?> <form /> <input type="checkbox" name="lev[]" value="PreK" /><font class="sm">PreK</font> <input type="checkbox" name="lev[]" value="Elem" /><font class="sm">Elem</font> <input type="checkbox" name="lev[]" value="MS" /><font class="sm">MS</font> <input type="checkbox" name="lev[]" value="HS" /><font class="sm">HS</font> <input type="checkbox" name="lev[]" value="College" /><font class="sm">College</font> <input type="submit" value=" ..:: Submit ::.. " /> Thank you. ~Wayne How to write the code to get the count of the word "CHECKED" from a row? I tried this and it's not working. Please help. $query = mysql_query("SELECT field1, field2, field3, COUNT(CHECKED) as counter FROM db1 WHERE row_name = 'science'"); while($line = mysql_fetch_array($query)) { echo $query['counter']; } |