Results 1 to 2 of 2

Thread: Code to delete records in PHP

  1. #1
    CollinsBrown is offline Senior Member
    Join Date
    Dec 2009
    Posts
    213
    Rep Power
    3

    Default Code to delete records in PHP

    Hi I am learning PHP programming language .I am developing one website in PHP. To create websites with a checkbox name chk_delete, when users check on it and press the Update button will perform a field delete the contents of the corresponding record in the database. Any help would be highly appericated..

  2. #2
    DavisNelson is offline Senior Member
    Join Date
    Dec 2009
    Posts
    202
    Rep Power
    3

    Default

    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>

Similar Threads

  1. Keep records safe in Mac OS X
    By HernandezOrtiz in forum Operating System
    Replies: 2
    Last Post: 07-12-2010, 01:32 PM
  2. LGA 1366 and ECC/records RAM
    By MartinWilson in forum RAM
    Replies: 1
    Last Post: 05-22-2010, 11:38 AM
  3. duplicate records in sql
    By Alan Knott in forum Programming
    Replies: 1
    Last Post: 04-14-2010, 12:12 PM
  4. Finding Records in VB6
    By ivor.hill in forum Programming
    Replies: 0
    Last Post: 01-08-2010, 05:11 PM
  5. Delete the folder office records
    By lynette in forum Windows XP
    Replies: 2
    Last Post: 04-17-2009, 06:28 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
SEO by SubmitEdge

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48