Amazon.com: PC Books || Educational Software || Magazines
Amazon: Books-CA || Software-CA || Books-UK || Software-UK

HTML | Javascript | ASP | PHP | VBScript | SQL | Hardware | PC FAQ| WinXP|

Learn to Build, Upgrade, or Repair your Computer Ebook + PC Safety 101 kwwebservice.com Reasonably priced web development & hosting
PHP Basics
Introduction
Variables & Arrays
Sub & Functions
If Statements
Case Statements
Loop Statements
Date Objects
Form Processing
Text File Objects
Database Access
Adding Record
Updating Record
Deleting Record
Virtual Includes
Cookies
Session
Server Variables
Creating Login Page
E-mail
PHP Books @
CA Amazon
UK Amazon
US Amazon

  :: Home
PC Topics
  :: Build A PC
  :: Windows XP
  :: PC Help
Tutorials
  :: HTML
  :: JavaScript
  :: ASP
  :: PHP
  :: VBScript
  :: SQL
Miscellaneous
  :: Code/Scripts
  :: Forum
  :: Links
  :: Contact us
  :: Tell A Friend
  :: In Somali
  ::
Web Articles
  Top Web Hosting
Reviews
  Processing
Online Card Payment Guide
  Domain name
registration & buying guide
  Getting
a website online guide
  Search Engine
submission & optimization tips
Netfirms Web Hosting
Free trial
Quality business correspondence.
Yahoo! Search Marketing


Delete a record

Remember we display the records to edit and selected the record we want. We are going to use the same method to delete a record. There are two files involved to delete a record.  First file (toDelete.php) is to view all the records and the second file (deleteComment.php) is to delete selected record.
Code to list records from feeds
toDelete.php
<head>
<title>Display feeds for edit</title>
</head>
<body >
<?php
include("connect.inc");
print "<table width='100%' border='1'>";
$query="SELECT * FROM feed";
$result=mysql_query($query);
$num=mysql_numrows($result);
print "<tr><td align='center'>Edit</td><td align='center'>Name</td></tr>";
$i=0;
while ($i < $num) {
$name=mysql_result($result,$i,"name");
$comments=stripslashes(mysql_result($result,$i,"comments"));
$id=mysql_result($result,$i,"user_id");
print "<tr><td><a href='deleteComment.php?id=$id'>Delete</a></td><td>$name</td></tr>";
$i++;
}
mysql_close($dbh);
print "</table>";
?>
</body>
</html>
The purpose of this file to view records and select one.   Selected record is deleted through deleteComment.php file.
deleteComment.php
<?php
include("connect.inc"); $msg="";
if(isset($_REQUEST['id']))
{
  $id=$_REQUEST['id'];
}
else
{
  $id=NULL;
  $msg =$msg." Wrong access. ID is null. <a href='toDelete.php'>Try again</a><br>";
}
if($id!=null)
{
  $query = "DELETE FROM feed WHERE user_id='$id'";
  mysql_query($query);
  $msg =$msg." Selected feed was successfully deleted... <a href='toDelete.php'>Delete another</a>";
}
print "<font color='red'>$msg</font>";
?>
No explanations were given since we are dealing with SQL statements combined with php, to learn more about SQL, go to our SQL section.
View the example demo

Update Data Virtual Includes
Bluehost.com Web Hosting $6.95
PC System Tools
SpyCleaner
Registry Mechanic
4Diskclean Pro
Health PC Club
TweakNow
Registry Washer
SpyAnyWhere
System Lifeguard
...More/Details

PC Articles
  Computer Safety
prevent viruses & Spyware