PHP - What Is The Correct Using Php To See If A Checkbox Is Checked Or Not.
What is the best way using php to see if a checkbox is checked or not.
I see so many different options out there googling, that I am interested knowing the most robust method. Thanks Similar Tutorialshi all I have 3 checkboxes whose values are getting stored in the database with a comma separator. Code: [Select] <input name="color[]" type="checkbox" value="red" id="red" />red <input name="color[]" type="checkbox" value="blue" id="blue" />blue <input name="color[]" type="checkbox" value="green" id="green" />green values getting stored with comma separator Code: [Select] red, blue, green now i want to show the checkboxes as "checked" to show the customer as which colors they chose lasttime when they submitted the form. How can i make it possible ? If it is possible without the comma separator then i can remove the comma. vineet Hi: How do I check to see if a checkbox has not been checked? Would the same rules apply to a radiobutton? This is what I have: Code: [Select] <input name="status[1]" id="approved" value="<?php echo $_POST['approved'] ?>" type="checkbox" /> <label for="approved">Approved</label> Code: [Select] if (isset($_POST['status[1]'])): $errMsg['status[1]'] = "Must select a status."; endif; I tested it out, but it just prints the error message even if I have checked it I am using the following piece of code to open a new window when a checkbox is checked... <INPUT type="checkbox" name="name" value="YES" onClick="window.open('/somepage.php?do=something&id=<?php echo $SOMEID["id"] ?>','','width=600,height=350,left=100,top=100,screenX=100,screenY=100')"> The page opens ok when the checkbox is ticked (checked). PROBLEM: The page opens again if the checkbox is un-ticked (un-checked). I just want to open the page if the checkbox is ticked only but not sure how to do this? OTHER INFO: Seperate checkboxes are dynamically created on the page for each id=<?php echo $SOMEID["id"] ?> This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=349419.0 Hello, Hope someone can help me cause i been at it all day and google woul'dn't help me. I been writing a little script which generates a list of numbers you can check and make a list of the numbers that have been checked. Now when i use $_get to the next page everything works but now i need to take the url and use $_get back to the generated check box list and it needs to know by the url which box had been checked and checked that one so the list can be altered. here is my code sofar Code: [Select] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>AH plaatjes.</title> </head> <body name="top"> Meer info beneden aan de pagina. <a href="#beneden">Naar beneden.</a> <p> <script language=JavaScript> function set(n) { temp = document.form1.elements.length ; for (i=0; i < temp; i++) { document.form1.elements[i].checked=n; } } function checkall() { void(d=document); void(el=d.getElementsByName('check')); for(i=0;i<el.length;i++) void(el[i].checked=1) } //invert function invers(){ temp = document.form1.elements.length ; for (i=0; i < temp; i++){ if(document.form1.elements[i].checked == 1){document.form1.elements[i].checked = 0;} else {document.form1.elements[i].checked = 1} } } </script> </p> <form id="form1" name="form1" method="get" action="./readlist.php"> <label>Naam eigenaar lijstje:<input name="naam" type="text" /></label> <label>Lijst van selectie plaatjes<select name="collect"> <option value="0">selecteer optie!</option> <option value="1">in decollectie</option> <option value="2">nog niet in collectie</option> <option value="3">dubbele collectie</option> </select></label> <p> <?php //TO Do trying to get the checkboxes checked with get and array ///////////////// do { $i = $i+1; echo " <input type=\"checkbox\" name=\"checked[]\" id=\"check\" value=\"". $i ."\"/> <label for=\"". $i ."\">". $i ."</label> <br /> "; if($i > 324){break;} }// end do while($i < 325); ?> </p><input name="check" type="submit" value="Print lijst" /> <input type=button onClick="checkall()" value="selecteer alles" name="button"> <input name=button onclick="invers()" type=button value=" Keer selectie om "> <INPUT name=button onclick=set(0) type=button value=" Reset "> </form> <p><a name="beneden">De geselecteerde nummers komen overzichtelijk in een lijstje. Zo heb je heel overzichtelijk een lijst met de nummers die je al hebt of juist nog niet hebt. Die kan je dan doorsturen selecteren en kopieren met je rechtermuis knop en naar je kennissen of vrienden sturen.</a> ook kan je de url (webadres) kopieren en doorgeven.</p> <p><a href="#top">Naar boven.</a></p> </body> </html> Now what i need is when you fill out an url like http://localhost/ah/index.php?checked%5B%5D=2&checked%5B%5D=3 it needs to check the same boxes. please help me out thanks in advance This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=349419.0 Hi all, I have been trying to figure this out for a few days already and can't seem to figure it out. I want to display a few images with a checkbox next to it so I can delete multiple images at once when I press the delete button. My problem is that I can't seem to figure out how to check if the checkbox is checked. if I uncheck one of them and click the delete button it deletes one from the array but I don't know which one was unchecked. For example if I uncheck the second one the array shows: Array ( => on [1] => on ) but I don't know which of the three was unchecked? Here is the code I have been testing with: Code: [Select] <?php // if submit button is clicked if(isset($_POST['submit'])) { // do delete function(); } // display deletethis[] array if (isset($_POST['deletethis'])) { echo "<pre>"; print_r ($_POST['deletethis']); echo "</pre>"; } $separate = array("http://funnypicturesimages.com/images/image/funny-dog-pictures.jpg", "http://1.bp.blogspot.com/-35wQMpYtNZc/TXWNx8y2xCI/AAAAAAAB_2o/9vZYNfWrGn8/s400/funny_demotivational_posters_01.jpg", "http://3.bp.blogspot.com/-TFnzZ8zFtgg/TXWNpodBkGI/AAAAAAAB_2Q/O_fOOSqFM6w/s400/funny_demotivational_posters_04.jpg"); echo '<form action="'.$_SERVER['PHP_SELF'].'" method="post">'; // display each image from array foreach ($separate as $value) { echo "<img src=".$value.">"; if ($_POST['deletethis'] = "on") { $checked="checked"; } else { $checked=""; } if ($_POST['deletethis'] != "") { echo "checked"; } else{ echo "unchecked"; } // if checkbox currently checked display it checked else display unchecked if ($checked == "checked") { echo '<input type="checkbox" name="deletethis[]" checked="checked"/><br /><br />'; } else { echo '<input type="checkbox" name="deletethis[]"/><br /><br />'; } } ?> <center><input type="submit" name="submit" value="Delete Checked"></center> </form> Hey guys, how do I send checkbox variables to my e-mail address once a user has checked it on the html form. Here is my html form: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Form</title> <script type="text/javascript"> //email form validation function everif(str) { var at="@" var punct="." var lat=str.indexOf(at) var lstr=str.length var lpunct=str.indexOf(punct) if (str.indexOf(at)==-1){ alert("Valid email must be entered") return false } if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){ alert("Valid email must be entered") return false } if (str.indexOf(punct)==-1 || str.indexOf(punct)==0 || str.indexOf(punct)==lstr){ alert("Valid email must be entered") return false } if (str.indexOf(at,(lat+1))!=-1){ alert("Valid email must be entered") return false } if (str.substring(lat-1,lat)==punct || str.substring(lat+1,lat+2)==punct){ alert("Valid email must be entered") return false } if (str.indexOf(punct,(lat+2))==-1){ alert("Valid email must be entered") return false } if (str.indexOf(" ")!=-1){ alert("Valid email must be entered") return false } return true } function evalid(){ var emailID=document.contact_form.mail if (everif(emailID.value)==false){ emailID.focus() return false } //empty field validation var naam=document.contact_form.naam if ((naam.value==null)||(naam.value=="")){ alert("Fields marqued with * must be entered") naam.focus() return false } var telefoon=document.contact_form.telefoon if ((telefoon.value==null)||(telefoon.value=="")){ alert("Fields marqued with * must be entered") telefoon.focus() return false } var branche=document.contact_form.branche if ((branche.value==null)||(branche.value=="")){ alert("Fields marqued with * must be entered") branche.focus() return false } return true } </script> </head> <body> <form name="contact_form" method="post" id="contactform" action="doeactie.php" onSubmit="return evalid()"> <table border="0"> <tr> <td><label for="bedrijfsnaam">Company name</label></td> <td colspan="2"><input name="bedrijfsnaam" type="text" class="text" size="30" /></td> </tr><tr> <td><label for="naam">Name *</label></td> <td colspan="2"><input name="naam" type="text" class="text" size="30" /></td> </tr><tr> <td><label for="mail">E-mail *</label></td> <td colspan="2"><input type="text" name="mail" class="text" size="30" /></td> </tr><tr> <td><label for="adres">Address</label></td> <td colspan="2"><input name="adres" type="text" class="text" size="30" /></td> </tr><tr> <td><label for="plaatsnaam">City</label></td> <td colspan="2"><input name="plaatsnaam" type="text" class="text" size="30" /></td> </tr><tr> <td><label for="postcode">Zip</label></td> <td colspan="2"><input type="text" name="postcode" class="text" size="10" /></td> </tr><tr> <td><label for="branche">Niche *</label></td> <td colspan="2"><input name="branche" type="text" class="text" size="30" /></td> </tr><tr> <td><label for="telefoon">Phone *</label></td> <td colspan="2"><input name="telefoon" class="text" type="text" size="30" /></td> </tr><tr> <td><label for="bericht">Question or Comment</label></td> <td colspan="2"><textarea name="message" class="text" onkeyup="return limitarelungime(this, 255)" cols="35" rows="5"></textarea></td> </tr> </table> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td></td> <td height="25"></td> </tr> <tr> <td></td> <td height="30" valign="top"><font face="arial" size="2"><b>I would also like to receive information about :</b></font></td> </tr> <tr> <td><input type="checkbox" name="emailmarketing" id="emailmarketing" value="emailmarketing" /></td> <td height="25"><font face="arial" size="2">E-mail Campaign</font></td> </tr> <tr> <td><input type="checkbox" name="zoekmachopt" id="zoekmachopt" value="zoekmachopt" /></td> <td height="25"><font face="arial" size="2">SEO</font></td> </tr> <tr> <td><input type="checkbox" name="socialmedia" id="id" value="socialmedia" /></td> <td height="25"><font face="arial" size="2">Social Media</font></td> </tr> <tr> <td><input type="checkbox" name="videomarketing" id="videomarketing" value="videomarketing" /></td> <td height="25"><font face="arial" size="2">Video Marketing</font></td> </tr> <tr> <td><input type="checkbox" name="webshop" id="webshop" value="webshop" /></td> <td height="25"><font face="arial" size="2">Webshop</font></td> </tr> <tr> <td><input type="checkbox" name="cms" id="cms" value="cms" /></td> <td height="25"><font face="arial" size="2">Content Management System</font></td> </tr> <tr> <td><input type="checkbox" name="grafisch" id="grafisch" value="grafisch" /></td> <td height="25"><font face="arial" size="2">Graphic Design</font></td> </tr> <tr> <td></td> <td align="left"><br /><input type="submit" name="Submit" value="Send"></td> <td align="right"></td> </tr> </table> </form> </body> </html> and this is the PHP script that processes this. Everything works except for the checkbox part. <?php session_start(); if(isset($_POST['Submit'])) { $youremail = 'blabla@gmail.com'; $fromsubject = 'Request from form'; $bedrijfsnaam = $_POST['bedrijfsnaam']; $naam = $_POST['naam']; $mail = $_POST['mail']; $adres = $_POST['adres']; $plaatsnaam = $_POST['plaatsnaam']; $postcode = $_POST['postcode']; $branche = $_POST['branche']; $telefoon = $_POST['telefoon']; $message = $_POST['message']; $to = $youremail; $mailsubject = 'Bericht ontvangen van'.$fromsubject.' Actie Pagina'; $body = $fromsubject.' Bedrijfsnaam: '.$bedrijfsnaam.' Naam Contact Persoon: '.$naam.' E-mail: '.$mail.' Adres: '.$adres.' Plaatsnaam: '.$plaatsnaam.' Postcode: '.$postcode.' Branche: '.$branche.' Telefoonnummer: '.$telefoon.' vraag of Wens: '.$message.' |---------End Message----------|'; echo "thank you for your request we will contact you asap."; mail($to, $subject, $body); } else { echo "Error Please <a href='form.html'>try again</a>"; } ?> Any help would be great! Thanks guys i have an html form which is a "post" on it i have an array of checkboxes and a sumbit button, once button is clicked i go to another page where i handle those boxes checked the problem now is if NO checkboxes are checked and i hit the submit...i get errors on the other page my code: foreach($product_names as $product_row) { ?> <tr> <td > </td><td width='200px'><?php echo $product_row->getName(); ?></td> <td width='200px'><input type="checkbox" name="graphic[]" value="<?php echo $product_row->getId();?>" /></td> <td width='200px'><input type="checkbox" name="text[]" value="<?php echo $product_row->getId();?>" /></td> </tr> <?php } ?> </table> <table> <tr> <td> <input type='submit' name='submit' value='Submit'> <?php if ( (isset($graphic)) || (isset($text) )) { echo "checkboxes checked"; //show submit button } else { //hide submit botton and echo "no boxes check"; } ?> the above is NOT working please help???? Hello,
I want to show checkbox is checked when there is entry of that id in a table in my database.
I have 2 tables page and access_level. I am getting data from page table and displays it in <ul><li> tag with checkbox to select all or only few. After selecting the checkbox, i will store only selected checkbox value in access_level table along with table id. Page link and page name details will be stored in page table.
Now if i want to edit , i should display all the pages which is there in page table and i should also mark checked to those which are already stored in access_level table.
I am using LEFT OUT JOIN, It displays all the pages. But it is not displaying the check mark to those which are already selected.
Here is my code
<?php $s1 = mysql_query("SELECT pages.page_id, pages.code, pages.page, pages.href, access_level.aid, access_level.page_id as pgid, access_level.department, access_level.position, access_level.active FROM pages LEFT OUTER JOIN access_level ON pages.page_id=access_level.page_id WHERE access_level.department=".$department." AND access_level.position=".$position." AND pages.code='sn'") or die(mysql_error()); while($s2 = mysql_fetch_array($s1)) { ?> <tr><td><li><?php echo $s2['page']; ?> </td><td><input type="checkbox" name="sn[]" value="<?php echo $s2['page_id']; ?>" <?php if($row['pgid'] === $s2['page_id']) echo 'checked="checked"';?> />here is my pages table pages.JPG 26.55KB 0 downloads access_level access_level.JPG 19.09KB 0 downloads In access_level table i do not have page ids 8 and 9. But i want to display that also from pages table and for 1 to 7 and 10 i should display check mark. How i can achieve this? Please Help I need bit of help, so I am looking into a plugin created for newsletter where default is it shows ad but it has option to remove ads by checking the check box. Default is to send ads in newsletter but if you don't want to send ads through newsletter then check the box. The problem is, it seems like checkbox selected is not being picked up. Some help would be appreciated. The custom field in wp:
'label' => 'Hide newsletter ads', 'name' => 'hide_ads', 'type' => 'checkbox', 'instructions' => 'Checking the checkbox will remove ads', 'required' => 0, 'conditional_logic' => 0, 'wrapper' => array( 'width' => '', 'class' => '', 'id' => '', ), 'choices' => array( 'Hide newsletter ads' => 'Hide newsletter ads', ), 'allow_custom' => 0, 'default_value' => array( ), 'layout' => 'block', 'toggle' => 0, 'return_format' => 'value', 'save_custom' => 0, ),
This is the php code for it: <!doctype html> <html lang="en-GB"> <head> <meta name="viewport" content="width=device-width" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta name="x-apple-disable-message-reformatting"> <title><?php the_title(); ?></title> <style> <?php require ABSPATH . 'path/newsletter.css'; ?> </style> <!--[if mso]> <style type="text/css"> .outlook-fallback-font { font-family: 'Lucida Bright', 'Cambria', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif; } </style> <![endif]--> </head> <?php $hide_newsletter_ads = get_field('hide_ads'); echo $hide_newsletter_ads; ?> <body itemscope itemtype="http://schema.org/EmailMessage"> <div class="wrap"> <?php if (!$hide_newsletter_ads) { include ABSPATH . 'path/ad-banner.php'; } ?> <div class="header"> <a href="<?php bloginfo( 'url' ); ?>"> <img src="<?php echo get_home_url().'logo.png' ?>" alt="News" /> </a> </div> <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <?php if ( get_field( 'newsletter_summary' ) ) { ?> <div class="newsletter-summary"><?php the_field( 'newsletter_summary' ); ?></div> <?php } ?> <?php if ( have_rows( 'newsletter_content' ) ) : ?> <?php // Loop through the ACF blocks $count = 0; while ( have_rows( 'newsletter_content' ) ) : the_row(); if ( get_row_layout() === 'story' ) : ?> <?php if ( 0 === $count ) { ?> <span class="date outlook-fallback-font"><?php the_time( 'd M Y' ); ?></span> <?php } ?> <?php if ( get_sub_field( 'story_heading' ) ) : ?> <h1><?php the_sub_field( 'story_heading' ); ?></h1> <?php endif; ?> <div class="content"> <?php the_sub_field( 'story_content' ); ?> </div> <?php endif; if ( 'post_list' === get_row_layout() ) : ?> <?php $posts = get_sub_field( 'post_list' ); if ( $posts ) : ?> </div> <div class="story-list"> <h2><span class="wrap"><?php the_sub_field( 'post_list_heading' ); ?></span></h2> <div class="wrap-table"> <table width="100%" cellpadding="0" cellspacing="0" border="0"> <?php // Output story cards foreach ( $posts as $i => $post ) { if ( 0 === $i % 2 ) { echo '<tr>'; } $class = ( 0 === $i % 2 ) ? 'odd' : 'even'; $image_src = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), array( 640, 345 ) ); $image_srcset = wp_get_attachment_image_srcset( get_post_thumbnail_id( $post->ID ) ); echo sprintf( '<td class="story-cell %4$s" valign="top"> <a href="%1$s" class="story-card outlook-fallback-font"> <img src="%3$s" alt="" height="120" style="height: 150px; object-fit: cover;" /> <span>%2$s</span> </a> </td>', esc_url( get_permalink( $post->ID ) . '?utm_source=newsletter&utm_medium=email&utm_campaign=newsletter' ), // permalink esc_html( get_the_title( $post->ID ) ), // title // esc_attr( $image_src[0] ), // image - src esc_attr( $image_src[0] ), // image - src esc_attr( $class ) // class ); if ( 0 !== $i % 2 || count( $posts ) === ( $i + 1 ) ) { echo '</tr>'; } } ?> </table> </div> </div> <div class="wrap"> <?php endif; endif; if (!$hide_newsletter_ads) { (0 === $count) { include ABSPATH . 'path/mpu-1.php'; } if (1 === $count) { include ABSPATH . 'path/mpu-2.php'; } } $count++; endwhile; endif; ?> <div class="footer"> <table width="100%" cellpadding="0" cellspacing="0" border="0"> <tr> <td align="left"> © <?php echo esc_html( date( 'Y' ) ); ?> </td> <td class="footer-link"> <a href="<?php echo get_permalink( get_page_by_path( 'privacy-policy' ) ); ?>">Privacy Policy</a> · <a href="%unsubscribe_url%">Unsubscribe</a> </td> </tr> </table> </div> </div> <?php endwhile; endif; ?>
It's pretty simple to see what I am trying to do here. For some reason all results in the table are the same exact cityName replacing all existing records. The echoed results are correct. I've include a small dump of my table as well. $query = "SELECT cityName FROM sys_city_dev_2"; $resource = mysqli_query($cxn, $query) or die("MySQL error: " . mysqli_error($cxn) . "<hr>\nQuery: $query"); while($result = mysqli_fetch_assoc($resource)) { $nox = $result['cityName']; $toUpper = ucfirst($nox); echo "$toUpper" . "<br />"; $setString = "UPDATE sys_city_dev_2 SET cityName = '" . $toUpper ."' WHERE cityName != ''"; mysqli_query($cxn,$setString); } 100 Records of table dump (pre running my script above): -- -- Table structure for table `sys_city_dev_2_backup` -- CREATE TABLE IF NOT EXISTS `sys_city_dev_2_backup` ( `ID` int(11) NOT NULL AUTO_INCREMENT, `Mid` int(11) NOT NULL DEFAULT '0', `cityName` varchar(30) NOT NULL DEFAULT '', `forder` int(4) NOT NULL DEFAULT '0', `disdplay` int(4) NOT NULL DEFAULT '0', `cid` int(11) NOT NULL DEFAULT '0', PRIMARY KEY (`ID`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=113970 ; -- -- Dumping data for table `sys_city_dev_2_backup` -- INSERT INTO `sys_city_dev_2_backup` (`ID`, `Mid`, `cityName`, `forder`, `disdplay`, `cid`) VALUES (84010, 1, 'dothan', 0, 0, 0), (84011, 1, 'alabaster', 0, 0, 0), (84012, 1, 'birmingham', 0, 0, 0), (84013, 2, 'flagstaff', 0, 0, 0), (84014, 1, 'auburn', 0, 0, 0), (84015, 1, 'florence', 0, 0, 0), (84016, 1, 'gadsden', 0, 0, 0), (84017, 1, 'huntsville', 0, 0, 0), (84018, 1, 'mobile', 0, 0, 0), (84019, 1, 'montgomery', 0, 0, 0), (84020, 1, 'tuscaloosa', 0, 0, 0), (84021, 2, 'mohave valley', 0, 0, 0), (84022, 2, 'phoenix', 0, 0, 0), (84023, 2, 'prescott', 0, 0, 0), (84024, 2, 'sierra vista', 0, 0, 0), (84025, 2, 'tucson', 0, 0, 0), (84026, 2, 'yuma', 0, 0, 0), (84027, 3, 'bakersfield', 0, 0, 0), (84028, 3, 'chico', 0, 0, 0), (84029, 3, 'fresno / madera', 0, 0, 0), (84030, 3, 'gold country', 0, 0, 0), (84031, 3, 'humboldt county', 0, 0, 0), (84032, 3, 'imperial', 0, 0, 0), (84033, 3, 'inland empire', 0, 0, 0), (84034, 3, 'los angeles', 0, 0, 0), (84035, 3, 'alhambra', 0, 0, 0), (84036, 3, 'merced', 0, 0, 0), (84037, 49, 'fayetteville', 0, 0, 0), (84038, 49, 'fort smith', 0, 0, 0), (84039, 49, 'jonesboro', 0, 0, 0), (84040, 49, 'little rock', 0, 0, 0), (84041, 49, 'arkadelphia', 0, 0, 0), (84042, 49, 'texarkana', 0, 0, 0), (84043, 3, 'modesto', 0, 0, 0), (84044, 3, 'alta sierra', 0, 0, 0), (84045, 3, 'alpine', 0, 0, 0), (84046, 3, 'pedley', 0, 0, 0), (84047, 3, 'redding', 0, 0, 0), (84048, 3, 'alondra park', 0, 0, 0), (84049, 3, 'sacramento', 0, 0, 0), (84050, 4, 'canon city', 0, 0, 0), (84051, 3, 'san luis obispo', 0, 0, 0), (84052, 3, 'santa barbara', 0, 0, 0), (84053, 3, 'stockton', 0, 0, 0), (84054, 3, 'aliso viejo', 0, 0, 0), (84055, 3, 'visalia', 0, 0, 0), (84056, 3, 'yuba city', 0, 0, 0), (84057, 4, 'boulder', 0, 0, 0), (84058, 4, 'colorado springs', 0, 0, 0), (84059, 4, 'denver', 0, 0, 0), (84060, 4, 'applewood', 0, 0, 0), (84061, 4, 'pueblo', 0, 0, 0), (84062, 4, 'air force academy', 0, 0, 0), (84063, 5, 'avon', 0, 0, 0), (84064, 5, 'hartford', 0, 0, 0), (84065, 5, 'new haven', 0, 0, 0), (84066, 5, 'ansonia', 0, 0, 0), (84067, 5, 'fairfield', 0, 0, 0), (84068, 7, 'daytona beach', 0, 0, 0), (84069, 7, 'sebastian', 0, 0, 0), (84070, 5, 'wallingford center', 0, 0, 0), (84071, 8, 'belvedere park', 0, 0, 0), (84072, 7, 'sarasota springs', 0, 0, 0), (84073, 7, 'sandalfoot cove', 0, 0, 0), (84074, 7, 'san carlos park', 0, 0, 0), (84075, 7, 'st. augustine', 0, 0, 0), (84076, 7, 'tallahassee', 0, 0, 0), (84077, 7, 'safety harbor', 0, 0, 0), (84078, 7, 'ruskin', 0, 0, 0), (84079, 8, 'athens-clarke county', 0, 0, 0), (84080, 8, 'atlanta', 0, 0, 0), (84081, 8, 'augusta-richmond county', 0, 0, 0), (84082, 8, 'brunswick', 0, 0, 0), (84083, 8, 'columbus', 0, 0, 0), (84084, 8, 'americus', 0, 0, 0), (84085, 8, 'acworth', 0, 0, 0), (84086, 8, 'valdosta', 0, 0, 0), (84087, 10, 'boise', 0, 0, 0), (84088, 10, 'ammon', 0, 0, 0), (84089, 10, 'moscow', 0, 0, 0), (84090, 10, 'blackfoot', 0, 0, 0), (84091, 10, 'twin falls', 0, 0, 0), (84092, 10, 'meridian', 0, 0, 0), (84093, 10, 'jerome', 0, 0, 0), (84094, 10, 'idaho falls', 0, 0, 0), (84095, 11, 'addison', 0, 0, 0), (84096, 10, 'garden city', 0, 0, 0), (84097, 10, 'eagle', 0, 0, 0), (84098, 10, 'chubbuck', 0, 0, 0), (84099, 10, 'caldwell', 0, 0, 0), (84100, 12, 'bloomington', 0, 0, 0), (84101, 12, 'evansville', 0, 0, 0), (84102, 12, 'fort wayne', 0, 0, 0), (84103, 12, 'indianapolis', 0, 0, 0), (84104, 12, 'muncie / anderson', 0, 0, 0), (84105, 12, 'lafayette / west lafayette', 0, 0, 0), (84106, 12, 'south bend / michiana', 0, 0, 0), (84107, 12, 'terre haute', 0, 0, 0), (84108, 12, 'northwest indiana', 0, 0, 0), (84109, 13, 'ames', 0, 0, 0); Hi guys, I wonder if any if you could help me: I have created a login page with "remember me" function... The page will redirect either to Admin Page or User Page depends their 'level'. But when I logged in as Admin and checked the box "remember me" and close all the browser to see IF the "remember me" work. When I open a new browser - and go to the index page - it is okay, I can view the page.... but it redirect me to the USER page NOT Admin page. Does anyone know why this happens? i am having issues checking which value is checked in a form. here is my code for it: Code: [Select] <input type="radio" name="accountActivation" id="no" value="no" checked=" <? if (isset($register_errors)) { if (($_POST['accountActivation']) == "no") { echo "checked"; } } ?> " /> when i first open the page, no is checked. why is this, when there should be no errors, and the radio should not even be checked in the first place? 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']; } This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=318750.0 <?php $goal = rand(1, 3); ?> <td><div align="left"> Goal</div></td> <td><label> <div align="center"> <input type="radio" name="goal_chk" id="radio2" value="1" <?php if($goal == "1") { echo "checked"; }?> /> </div> </label></td> <td><label> <div align="center"> <input name="goal_chk" type="radio" id="radio13" value="2" <?php if($goal == "2") { echo "checked"; }?> /> </div> </label></td> <td><label> <div align="center"> <input type="radio" name="goal_chk" id="radio23" value="3" <?php if($goal == "3") { echo "checked"; }?> /> </div> </label></td> </tr> i have a group of radio buttons whose value is checked randomly everytime you refresh the page, now that works fine, everytime you refresh the page the checked values moves randomly but the problem i have is getting the actual of a checked radio button. i have tried this... $goal_checked = $_POST['goal_chk']; echo $goal_checked; But nothing happens. Any ideas on how to make this possible. Thanks a lot you guys. I am creating a while loop puts a checkmark in a check box when two variables match. The code works till I place a checkmark in a check box. When that happens I get this error message :Fatal error: Uncaught Error: Call to a member function bind_param() on boolean. I can't figure out what is causing this to error out. This is the code that I am using <fieldset> <legend>Categories</legend> <?php $stmt2 = mysqli_query($db, 'SELECT catID, catTitle FROM blog_cats ORDER BY catTitle'); while($row2 = mysqli_fetch_assoc($stmt2)){ $stmt3 = $db->prepare('SELECT catID FROM blog_post_cats WHERE catID = ? AND postID = ?') ; $stmt3->bind_param("ii", $row2['catID'], $postID); $stmt3->execute(); $stmt3->bind_result($row3catID); $stmt3->fetch(); if($row3catID == $row2['catID']){ $checked = 'checked = "checked"'; } else { $checked = null; } echo '<input type="checkbox" name="catID[]" value="'.$row2['catID'].'" '.$checked.'>'.$row2['catTitle'].'<br />'; } ?> </fieldset> This is what the source looks like when using google chrome <fieldset> <legend>Categories</legend> <input type="checkbox" name="catID[]" value="2" >Development<br /><input type="checkbox" name="catID[]" value="9" >Earn Money From Home<br /><input type="checkbox" name="catID[]" value="1" checked = "checked">General<br /><br /> <b>Fatal error</b>: Uncaught Error: Call to a member function bind_param() on boolean in /storage/ssd2/059/12276059/public_html/admin/edit-post.php:141 Stack trace: #0 {main} thrown in <b>/storage/ssd2/059/12276059/public_html/admin/edit-post.php</b> on line <b>141</b><br /> The first two first two empty check boxes work just fine then the third is checked and after that the code stops working, I don't understand why. |