eddlandos Posted July 3, 2011 Share Posted July 3, 2011 function showpicturedelete() { if (isset($_POST['submit'])) { $default = 0; if(isset($_POST['default'])) { $default = $_POST['default']; } $picture = $_POST['picture']; $this->connect(); $result = mysql_query("UPDATE `profilepicture` SET `default` ='$default' WHERE `big` ='$picture'"); echo $result; $this->close(); } if(isset($_SESSION['userName'])) { $this->connect(); $username = $_SESSION['userName']; $result = mysql_query("SELECT * FROM `profilepicture` WHERE `username` = '$username'"); while($row = mysql_fetch_array($result)) { $picture = $row['big']; $picturethumb = $row['small']; $default = $row['default']; ?> <form action="<?php echo $_SERVER['PHP_SELF']?>" method="post"> <?php echo '<a class="thumb" name="thumb" href="' .$picture. '" title="Title #0">'; echo '<img src="' .$picturethumb. '" alt="Title #0" /></a>'; ?> <input type="radio" name="default"<?php if($default == 1) { echo ' checked="checked"'; } ?> value="<?php echo $default; ?>" /> <?php echo '<input name="picture" type="hidden" value="'.$picture.'"/>'; } echo '<input type="submit" name="submit" value="submit"/></form>'; ?> <script> function confirmDelete(delUrl) { if (confirm("Are you sure you want to delete")) { document.location = delUrl; } } </script> <input type=button value="Delete" onClick="javascript:confirmDelete('delete.php?big=<?php echo $picture;?>&small=<?php echo $picturethumb;?>')"> <?php $this->close(); } } Quote Link to comment https://forums.phpfreaks.com/topic/240990-why-dont-my-radio-buttons-work/ Share on other sites More sharing options...
wildteen88 Posted July 3, 2011 Share Posted July 3, 2011 What should the code be doing? What are you trying to do? Quote Link to comment https://forums.phpfreaks.com/topic/240990-why-dont-my-radio-buttons-work/#findComment-1237862 Share on other sites More sharing options...
eddlandos Posted July 3, 2011 Author Share Posted July 3, 2011 it should be updating the value default to 1 if it is selected... it seems to be a form/checkbox problem as I've tried it with text input fields Quote Link to comment https://forums.phpfreaks.com/topic/240990-why-dont-my-radio-buttons-work/#findComment-1237866 Share on other sites More sharing options...
eddlandos Posted July 3, 2011 Author Share Posted July 3, 2011 Anyone have any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/240990-why-dont-my-radio-buttons-work/#findComment-1237968 Share on other sites More sharing options...
sunfighter Posted July 3, 2011 Share Posted July 3, 2011 Who can read this code? BTW you only have one radio button, you should change it's id, name. Don't think a name of default is good. Quote Link to comment https://forums.phpfreaks.com/topic/240990-why-dont-my-radio-buttons-work/#findComment-1237971 Share on other sites More sharing options...
jcbones Posted July 3, 2011 Share Posted July 3, 2011 It looks to me like you are setting the value of your radio button to the current default setting, thereby never changing it's value. //change: value="<?php echo $default; ?>" /> //to value="1" /> Quote Link to comment https://forums.phpfreaks.com/topic/240990-why-dont-my-radio-buttons-work/#findComment-1237988 Share on other sites More sharing options...
eddlandos Posted July 5, 2011 Author Share Posted July 5, 2011 that didn't change anything unfortunately Quote Link to comment https://forums.phpfreaks.com/topic/240990-why-dont-my-radio-buttons-work/#findComment-1238609 Share on other sites More sharing options...
jcbones Posted July 6, 2011 Share Posted July 6, 2011 For de-bugging purposes, lets show the query: Change this line: $result = mysql_query("UPDATE `profilepicture` SET `default` ='$default' WHERE `big` ='$picture'"); To: $sql = "UPDATE `profilepicture` SET `default` ='$default' WHERE `big` ='$picture'" $result = mysql_query($sql) or trigger_error($sql . ' has failed. <br /> ' . mysql_error()); echo 'DEBUG -> ' . $sql . '<br />'; Now, try selecting the radio button, and then try it with the button un-selected. The query should change from 1 to 0. [/code] Quote Link to comment https://forums.phpfreaks.com/topic/240990-why-dont-my-radio-buttons-work/#findComment-1238751 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.