php - Set mysql values from radio buttons in html form -


i want 2 radio buttons on webpage (written in php) representing "yes" , "no". when load page want fetch value mysql db , set corresponding radio button. , when click on other button, want update database , reload page.

i'm trying simple html form, no luck. code have far (that not working @ :( is:

if (!isset($_post['submit'])) {     $sql = "select challenge_me contestants id=$id";     $res = (mysql_fetch_assoc(mysql_query($sql, $db)));     $challenge_me = $res["challenge_me"];  }else{     $sql = "update contestants set challenge_me='" . $_post['yesno'] . "' id='$id'";     if(!mysql_query($sql, $db))         echo mysql_error(), "<br/>query '$sql'";     $challenge_me = $_post['yesno']; }      echo'<form method="post" action="' . $php_self . '">';     echo '<input type="hidden" name="submit" value="submit">';           if($challenge_me == 1){     echo'<input type="radio" name="yesno" value="1" onclick="this.form.submit();" checked>yes ';     echo'<input type="radio" name="yesno" value="0" onclick="this.form.submit();">no '; }else{     echo'<input type="radio" name="yesno" value="1" onclick="this.form.submit();">yes ';     echo'<input type="radio" name="yesno" value="0" onclick="this.form.submit();" checked>no '; } echo'</form>';   

your script doesnt seem define $id, $id value from? source of problem. script might not passing value in $id


Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -