briguy9872 Posted April 5, 2006 Share Posted April 5, 2006 [!--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 0When 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);?><?phpinclude '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 https://forums.phpfreaks.com/topic/6618-how-to-add-column-to-existing-table/ Share on other sites More sharing options...
khendar Posted April 5, 2006 Share Posted April 5, 2006 [!--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 https://forums.phpfreaks.com/topic/6618-how-to-add-column-to-existing-table/#findComment-24060 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.