Your Ad Here

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




 Sponsors
 Links
finance products
gambling sites
programmershelp
 Downloads
dzphp editor
EasyPHP
mysql_phpgenerator
php-studio-trial
phpdesigner_7_2_5
phpMyAdmin-3.4.3.2
/phptriad2-2-1
phpxedit_321
rapidphp 2011
WampServer2.1d-x64
WampServer2.1e-x32
xampp-win32-1.7.4-VC6-installer
xampplite-win32-1.7.3
 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
List all files in a directory and place them in a select menu(file system)
HTML special characters(internet)
getprotobynumber function(functions)
 Random Article
  Network
Programming resources
Tutorials directory
Hosting resources
ASP site
Domain names
Progged
Maxi directory
bigarticle : free articles
A Code
Code N Tutorials
Get PHP
Programmers help




beginners PHP Copyright © 2004 onwards by beginnersPHP.