Chris Coin Posted April 3, 2006 Share Posted April 3, 2006 is ther a way to delete a post, posted to another php fileExample: "index.php" post to "info.php"id like the "info.php" to display somthing like this:name: (name)link: (link)description: (description)[!--coloro:#CC0000--][span style=\"color:#CC0000\"][!--/coloro--]Delete this link[!--colorc--][/span][!--/colorc--] <---this would be a link that would delete the above lines and the only above lines, because ther will be info before and after it.is somthin like this possible? Quote Link to comment Share on other sites More sharing options...
realjumper Posted April 3, 2006 Share Posted April 3, 2006 The 'Delete this link' just has to have the id variable of the record in the url....like for example[code]echo "<a href=\"delete.php?id=$id\">Delete this link</a>";[/code]and on the delete.php page[code]$id=$_GET['id'];mysql_query("DELETE FROM your table WHERE id=$id");[/code] Quote Link to comment Share on other sites More sharing options...
Chris Coin Posted April 3, 2006 Author Share Posted April 3, 2006 [!--quoteo(post=361071:date=Apr 2 2006, 08:57 PM:name=realjumper)--][div class=\'quotetop\']QUOTE(realjumper @ Apr 2 2006, 08:57 PM) [snapback]361071[/snapback][/div][div class=\'quotemain\'][!--quotec--]The 'Delete this link' just has to have the id variable of the record in the url....like for example[code]echo "<a href=\"delete.php?id=$id\">Delete this link</a>";[/code]and on the delete.php page[code]$id=$_GET['id'];mysql_query("DELETE FROM your table WHERE id=$id");[/code][/quote]thanks alot,but i dont know if this will work, because when "submit.php" post to "info.php" it will create the same id for each post , then the delete link will delete all the post with same id, am i right? Quote Link to comment Share on other sites More sharing options...
realjumper Posted April 3, 2006 Share Posted April 3, 2006 I'm assuming that on info.php you will have a list like....name: (whatever)link: (whatever)description: (whatever)Delete this linkname: (foo)link: (foo)description: (foo)Delete this linkname: (stuff)link: (stuff)description: (stuff)Delete this linkIf so.....this information will come from a select query. Something like...[code]$result = mysql_query("SELECT name,link,description,id FROM table") or die(mysql_error());echo "<table>";while(list($name, $link, $description, $id)=mysql_fetch_array($result)){ echo "<tr>"; echo "<td>$name</td></tr>"; echo "<tr><td>$link</td></tr>"; echo "<tr><td>$description</td></tr>"; echo "<tr><td><a href=\"delete.php?id=$id\">Delete This Link</a></td></tr>"; }echo "</table>";[/code]....the above should do it Quote Link to comment Share on other sites More sharing options...
Chris Coin Posted April 3, 2006 Author Share Posted April 3, 2006 [!--quoteo(post=361388:date=Apr 3 2006, 06:08 PM:name=realjumper)--][div class=\'quotetop\']QUOTE(realjumper @ Apr 3 2006, 06:08 PM) [snapback]361388[/snapback][/div][div class=\'quotemain\'][!--quotec--]I'm assuming that on info.php you will have a list like....name: (whatever)link: (whatever)description: (whatever)Delete this linkname: (foo)link: (foo)description: (foo)Delete this linkname: (stuff)link: (stuff)description: (stuff)Delete this linkIf so.....this information will come from a select query. Something like...[code]$result = mysql_query("SELECT name,link,description,id FROM table") or die(mysql_error());echo "<table>";while(list($name, $link, $description, $id)=mysql_fetch_array($result)){ echo "<tr>"; echo "<td>$name</td></tr>"; echo "<tr><td>$link</td></tr>"; echo "<tr><td>$description</td></tr>"; echo "<tr><td><a href=\"delete.php?id=$id\">Delete This Link</a></td></tr>"; }echo "</table>";[/code]....the above should do it[/quote]Yeah this is perfect.is ther a way to do the same thing if i was posting to a flat file? Quote Link to comment Share on other sites More sharing options...
realjumper Posted April 3, 2006 Share Posted April 3, 2006 A flat file.....hmmm...I could be wrong but I very much doubt it because the id is the unique identifier, which is incremented by one every time a new record is inserted in the db....something a flat file cannot do automatically. Quote Link to comment Share on other sites More sharing options...
Chris Coin Posted April 3, 2006 Author Share Posted April 3, 2006 [!--quoteo(post=361393:date=Apr 3 2006, 06:24 PM:name=realjumper)--][div class=\'quotetop\']QUOTE(realjumper @ Apr 3 2006, 06:24 PM) [snapback]361393[/snapback][/div][div class=\'quotemain\'][!--quotec--]A flat file.....hmmm...I could be wrong but I very much doubt it because the id is the unique identifier, which is incremented by one every time a new record is inserted in the db....something a flat file cannot do automatically.[/quote]thats what i thought, but i just wanted to make sure.it wouldnt work because when you would press the delete link, since the form would submit the same id to all post then it would delete all the post in the flat file.am i right?unless ther is away to make a script that would give out random numbers as the id, but i gess random isnt so random somtimes so maybe eventually you might delete more then one post. Quote Link to comment Share on other sites More sharing options...
realjumper Posted April 3, 2006 Share Posted April 3, 2006 I'm sure if you got creative and put on your thinking cap it could be done.....but it's simple when using a database rather than a flat file, so being a lazy person I choose the database every time!! :-) Quote Link to comment Share on other sites More sharing options...
Chris Coin Posted April 3, 2006 Author Share Posted April 3, 2006 [!--quoteo(post=361397:date=Apr 3 2006, 06:37 PM:name=realjumper)--][div class=\'quotetop\']QUOTE(realjumper @ Apr 3 2006, 06:37 PM) [snapback]361397[/snapback][/div][div class=\'quotemain\'][!--quotec--]I'm sure if you got creative and put on your thinking cap it could be done.....but it's simple when using a database rather than a flat file, so being a lazy person I choose the database every time!! :-)[/quote]haha i hear what your saying,im goin to try with a flat file and see if i can come up with somthing....Thanks for all the help. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.