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
https://forums.phpfreaks.com/topic/16682-change-table-data/
Share on other sites

  • 5 weeks later...

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.