Your Ad Here

 Navigation
Home
Source code
Tutorials
RSS feeds
Articles
Wordpress plugins
Blog
Books
Software
Downloads
Hosting
manuals
Script directory
Training
Our Links




 Sponsors
 Links
dvd information
low cost magazines
domain names
 Downloads
 Misc
Webmaster Resources
Only PHP
ScriptSearch.com
Scripts.com - Get the best scripts NOW!
AndreaPHP Programming

Valid XHTML 1.0 Transitional


Valid CSS!


Delete from a database


Delete from a database

This is our last part , we have added links to our database and we have displayed these links but damn there are some incorrect links and we need to delete , no problem we will guide you through this .

In this script we will again create a form in which the user/admin enters the link and this is then deleted from the database , if no data is entered then a message is displayed . We could also have deleted links by using their id values but we would probably keep that as an admin function , this example is more for the likes of say a user submitted links site like www.aspin.com for example.

Here is the code for the form , again nothing tricky here.

<form action="deletingfromadb1.php" method ="POST">
<input type = "text" name = "delete" maxlength="50"><br>
<input type = "submit" value = "delete link"><br>
</form>

Now for the script which in this case is called deletingfromadb1.php , remember and add your own details instead of the following section ("hostname","username" ,"password")

<?php
//make our connection details
$connection = mysql_connect("hostname","username" ,"password")
or die ("Cannot make the connection");
//connect to sampledb with our connection details
$db = mysql_selectdb("sampledb" , $connection)
or die ("Cannot connect to the database");
//if the text field wasnt blank enter data
if($delete)
{
//insert the text box data into the sample table
$sql_query = "DELETE FROM sample WHERE link = ('$delete')";
$result = mysql_query($sql_query);
//display the entered link
echo "You entered the following info " . $delete;
echo "<a href='testingourdb.php'>Back to test page</a>";
}
//if it was display a message
else
{
echo ("you didnt enter any data");
}
?>




Books
 Sponsors
 Random Code
Yahoo news(xml)
Random number examples(randomizing)
Creating a table in a MySQL database(database)
 Random Article
  Network
Programming resources
Tutorials directory
Clickbank mall
sell software
Free auctions, low cost stores
UK products
US products
Gambling directory
Sexy free wallpapers
Hosting resources
ASP site
DVD site
Domain names
Dating site
Software directory
Maxi directory
bigarticle : free articles




beginners PHP Copyright © 2004 onwards by beginnersPHP.