martynball
New Member
- Messages
- 60
- Reaction score
- 0
- Points
- 0
It all works, but I have to put the "ID" value in the php code. How do I drag in a value from a text field?
delete.php:
Better yet, is there a way I can add a link to click on each row which will delete that row when displaying the data with this?:
PHP:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Administator Tools</title>
</head>
<body>
<form name="dr" action="scripts/delete-r.php" id="dr">
Delete by ID:<br />
<input type="text" name="ID" size="4">
<br />
<br />
Delete by Name:<br />
<input type="text" name="NAME" size="30">
<br />
<br />
Delete by Email:<br />
<input type="text" name="EMAIL" size="30">
<br />
<br />
Delete by IP(WIP):<br />
<input type="text" name="IP" size="20">
<br />
<input type="submit">
</form>
</body>
</html>
delete.php:
PHP:
<?
mysql_connect('localhost', 'martynba_martynb', 'password') or die('Error: ' . mysql_error());
mysql_select_db('martynba_comments') or die('Error (DB): ' . mysql_error());
$del = mysql_query("DELETE FROM commentTable WHERE ID='22'");
if (!$del)
{
die('Error: ' .mysql_error());
}
?>
Better yet, is there a way I can add a link to click on each row which will delete that row when displaying the data with this?:
PHP:
<?php
// Connect to the database server
mysql_connect('localhost', 'martynba_martynb', 'password') or die('Error connecting to the database, MySQL returned: ' . mysql_error());
// Select the database
mysql_select_db('martynba_comments') or die('Error selecting database, MySQL returned: ' . mysql_error());
//Build query
$query = mysql_query("SELECT * FROM commentTable");
//Display results
while ($row = mysql_fetch_array($query)) {
echo "<br /> ID: " .$row['ID'].
"<br /> First Name: ".$row['FNAME'].
"<br /> Last Name: ".$row['LNAME'].
"<br /> Phone Number: ".$row['PHON'];}
?>
Last edited: