Hello,
Thanks for helping me. I tried all your tips but its still not working.
I believe i'm not understanding the rowid attribute. When you say normally numeric, where are you talking about in my code?
Here is my database structure.
+------------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------+-------------+------+-----+---------+-------+
| name | varchar(15) | | PRI | | |
| email | varchar(20) | | | | |
| password | varchar(15) | | | | |
| department | varchar(20) | | | | |
+------------+-------------+------+-----+---------+-------+
4 rows in set (0.02 sec)
Here are codes again.
<body>
<center>
<h1>Student Records List</h1>
<?
$sql = "SELECT * from students";
If ($name)
$sql .= "name like '%$name%' and ";
If ($email)
$sql .= "email like '%$email%' and ";
If ($password)
$sql .= "password like '%$password%' and ";
If ($department)
$sql .= "department like '%$department%' and ";
$connection = mysql_connect("localhost","univrel","univrel") or die ("Couldn't connect to server.");
$db = mysql_select_db("univrel",$connection) or die ("Couldn't connect to database.");
$sql_result = mysql_query($sql,$connection);
?>
<table border=\"1\" cellspacing=\"5\" cellpadding=\"3\">
<tr>
<td align="center"><b>Name</b></td>
<td align="center"><b>Email Address</b></td>
<td align="center"><b>Password</b></td>
<td align="center"><b>Department</b></td>
<td align="center"><b>Modify/Delete</b></td>
</tr>
<?
while (($row = mysql_fetch_object($sql_result)))
{
printf("<tr>
<td>%s</td>
<td>%s</td>
<td>%s</td>
<td>%s</td>
<td><a href=\"modify.php3?rowid=%s\"><I>Modify</I></a>|<a href=\"delete.php3?rowid=%s\"><I>Delete</I></a></td>
</tr>\n", $row->name, $row->email, $row->password, $row->department, $row->ROWID, $row->ROWID);
}
printf("</table>\n");
mysql_free_result($sql_result);
?>
</form>
</center>
</body>
<?
$sql = "DELETE from students where ROWID=$rowid";
$connection = mysql_connect("localhost","univrel","univrel") or die ("Couldn't connect to server.");
$db = mysql_select_db("univrel",$connection) or die ("Couldn't connect to database.");
$result = mysql_query($sql, $connection);
echo ("Record deleted for $name");
// If ($result == 0)
{
// echo ("ERROR: RECORD NOT DELETED!");
}
// else
{
// echo ("Record deleted!");
}
?>