Jump to content

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]

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.