Suppose you have a database containing many tables, including table named Categories contain multiple records, every record contains the fields UserID, UserName, Description ... You can create a website consists of two files DeleteRecord.php DeleteRecord.htm and allows users to type the code of record should be deleted UserID, and then delete this record user requests as follows:
1. Create a folder in particular locations DeleteRec disk;
2. Use a text editor familiar with (such as NotePad, WordPad ...) wrote DeleteRecord.htm file with the following contents and the directory containing the file you just created:
Code:
<html>
<head> </ head>
Website contains <title> input form </ title>
<body>
<form Action="DeleteRec.php" method=post>
Enter the code should delete UserID:
<input Name=txtCatID style="width: 269px; height: 22px">
<input Type=submit <p> value="Xoa record"> </ P>
</ FORM>
</ Body>
</ Html>
Use a text editor familiar with (such as Notepad, WordPad ...) wrote DeleteRec.php deleted file records request with the following contents and the directory containing the file you just created:
Code:
<html>
<head>
Delete records by <title> UserID </ title>
</ Head>
<body>
<? Php
# Define the user code entered from the form UserID
$ CatID = $ _POST ["txtUserID"];
# Create a bridge to the database are identified by DNS name "Northwind"
$ Connect = odbc_connect ("Northwind", "", "");
# Create query
$ Query = "DELETE FROM Categories WHERE UserID = $ catID";
echo "The query <p> need to do is: $ query </ p>";
# Execute query
$ Result = odbc_exec ($ connect, $ query);
echo "<p> perform query results is: $ result </ p>";
# Close the bridge to the database
odbc_close ($ connect);
?>
<p>
<a href="DeleteRecord.htm"> Back to home </ a>
</ Body>
</ Html>
Bookmarks