Jump to content

Why don't my radio buttons work?


eddlandos

Recommended Posts

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();
}
}

Link to comment
https://forums.phpfreaks.com/topic/240990-why-dont-my-radio-buttons-work/
Share on other sites

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]

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.