Jump to content

change table data


proctk

Recommended Posts

below is code that 'm try use create to delete change table data based on the value in a column

if column user_id has a value and column Otheruser_id is balk I want the table row deleted

if the column Otheruser_id has a value and the user that has a value in column user_id wants to remove themself form the profile i want to give the option to change the value in the colum user_id to blank

If the the value in column Otheruser_id is blank and the user wants to remove themself from the profile then I want the table row to be deleted.

hope this makes sense any help is great

thank you

[code=php:0]
<title>Delete Child</title>

<?

include 'db.php';

$user_id = $_REQUEST['id'];

$sql_delete_child = mysql_query("SELECT * FROM children WHERE user_id = '$user_id'
OR Otheruser_id = '$user_id'");

  $delete_child_found = mysql_fetch_array($sql_delete_child) or die(mysql_error());

$chid_id = $delete_child_found['user_id'];
$Otheruser_id = $delete_child_found['Otheruser_id'];

if($child_id == $user_id){
mysql_query("UPDATE children SET user_id = 'null' WHERE user_id='$user_id'");

}

if($user_id == $Otheruser_id){
mysql_query("UPDATE children SET Otheruser_id = 'null' WHERE Otheruser_id='$user_id'");

}

if($child_id == $user_id and $Otheruser_id <= 0){
mysql_query("DELETE FROM children WHERE user_id = '$user_id'") or die(mysql_error());

}

include 'getchildren.php';


?>

[/code]
Link to comment
Share on other sites

I want to give users the ability to remove thier user_id from a table.  the columns where their user_id could be found is column "user_id" or "Otheruser_id".  There will be a link next to the information that will update the table.

Link to comment
Share on other sites

  • 5 weeks later...
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.