Jump to content

How to add column to existing table


briguy9872

Recommended Posts

[!--quoteo(post=361416:date=Apr 3 2006, 07:40 PM:name=khendar)--][div class=\'quotetop\']QUOTE(khendar @ Apr 3 2006, 07:40 PM) [snapback]361416[/snapback][/div][div class=\'quotemain\'][!--quotec--]
The rest is simple:
Add a new column to your `pm` table which is called `trash`.
Set the default value of `trash` to false - or no - or 0
When someone deletes their message, dont ACTUALLY delete it, just change the value of the `trash` field to true - or yes - or 1.
[/quote]
I really don't know how to do that. PLEASE WALK me through that. Here is DELPM.php
[code]
<body bgcolor="green">
<? error_reporting(E_ERROR);?>
<?php

include 'dbconnect.php';
include 'styleb.css';
session_start();




if (isset($_SESSION['user']))
  {
    $user=$_SESSION['user'];
    $getuser="SELECT * from register where userid='$user'";
    $getuser2=mysql_query($getuser) or die("Could not get user info");
    $getuser3=mysql_fetch_array($getuser2);
    print "<center>";
    print "<table class='maintable'>";
    print "<tr class='linktable'><td><center>Delete PM</td></tr>";
    print "<tr class='posttable'><td>";
   $user2=$_SESSION['user'];
$ID = $_POST['id'];
    $getyourpms="SELECT * from pm as a,register as b where a.reciever='$user' and b.userid=a.sender and subject='$ID'";
    $getyourpms2=mysql_query($getyourpms) or die(mysql_error());
    while($getyourpms3=mysql_fetch_array($getyourpms2))
     $trash="INSERT into trash(sender,reciever,date,subject,message,status,time)
value('$getyourpms3[sender]','$getyourpms3[reciever]','$getyourpms3[date]','$getyourpms3[subject]','$getyourpms3[message]','$getyourpms3[status]','$getyourpms3[time]')";
       mysql_query($trash) or die("Could not put in trash can");
  
       $delpm="DELETE FROM pm where reciever='$user' and subject='$ID'";
       mysql_query($delpm) or die("Could not delete message");
       print "PM deleted, back to <A href='pmbox.php'>PM Main</a>";

}
    else
    {
       print "Are you sure you want to delete this PM?<br>";
       print "<form action='delpm.php' method='post'>";
       print "<input type='submit' name='submit' value='delete'></form>";
    
}

  
  

print "</td></tr></table>";      
    print "<font size='1'>Script Produced by <A href='http://www.tfws.dynu.com'>TFWS Scripts</a></font>";
    
  
?>

[/code]
Now.. What do I put in mysql database. I assume that in table pm i put a field trash. Ok.. so i did. what are the values I should put. what is the default. after that, what should i change in delpm.php??? PLEASE PLEASE HELP!!!!! PLEEAAAASE!
Link to comment
Share on other sites

[!--quoteo(post=361794:date=Apr 5 2006, 10:51 AM:name=briguy9872)--][div class=\'quotetop\']QUOTE(briguy9872 @ Apr 5 2006, 10:51 AM) [snapback]361794[/snapback][/div][div class=\'quotemain\'][!--quotec--]
[b]1.[/b] I assume that in table pm i put a field trash.
what are the values I should put.
[b]2.[/b] what is the default.
[b]3.[/b]after that, what should i change in delpm.php??
[/quote]
[!--quoteo(post=361416:date=Apr 3 2006, 07:40 PM:name=khendar)--][div class=\'quotetop\']QUOTE(khendar @ Apr 3 2006, 07:40 PM) [snapback]361416[/snapback][/div][div class=\'quotemain\'][!--quotec--]
[b]1.[/b] Add a new column to your `pm` table which is called `trash`.
[b]2.[/b] Set the default value of `trash` to false - or no - or 0
[b]3.[/b] When someone deletes their message, dont ACTUALLY delete it, just change the value of the `trash` field to true - or yes - or 1.
[/quote]

You should use whatever values you want. I'd suggest use an enum and have true/false but you could use yes/no, 0/1 whatever you want.

Instead of inserting the pm into the trash table, and then deleting the pm from the pm table, just do an update on the pm table:

$query = "UPDATE `pm` set `your_trash_field` = 'true' "

BTW there was really no need to post a new thread on this.
Link to comment
Share on other sites

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.