deleting recordset from database via an admin page
Moderator: General Moderators
deleting recordset from database via an admin page
Hi there
I've got a form for someone to add news items to a page which is fine. On an admin page I'm displaying the news items and want to put a delete button by each so they can be deleted when redundant.
I've tried doing this by identifying the id in the table and then deleting it but I'm going round in circles...
Any suggestions?
Thanks in advance
I've got a form for someone to add news items to a page which is fine. On an admin page I'm displaying the news items and want to put a delete button by each so they can be deleted when redundant.
I've tried doing this by identifying the id in the table and then deleting it but I'm going round in circles...
Any suggestions?
Thanks in advance
What I have is a repeated region to show the results. Where I'm confused is where to tag the $query, which would be
What would be ideal is to have a setion at the end where the user can enter in a form field the id number of the row that they want to delete, but I'm stuck on how to phrase that within the query above.
Code: Select all
$query = "DELETE FROM news WHERE .....";to just expand that
is returning this error
Parse error: syntax error, unexpected T_STRING in C:\apachefriends\xampp\xampp\htdocs\Royalbluecms\admin.php on line 209
Code: Select all
<form name="form1" id="form1" method="post" action="">
<input name="idnumber" type="password" id="idnumber" />
<input name="Delete Item" type="submit" id="Delete Item2" value="Delete Item" />
</form>Code: Select all
<?php> mysql_select_db($database_Royalbluecms, $Royalbluecms);
$query = "DELETE FROM news SET id WHERE id="idnumber"";
$result = "mysql_query($query) or die ("Couldn't execute query");
<?>Parse error: syntax error, unexpected T_STRING in C:\apachefriends\xampp\xampp\htdocs\Royalbluecms\admin.php on line 209
Should be pretty obvious with syntax highlighting.
Code: Select all
$query = "DELETE FROM news SET id WHERE id=".$idnumber;
$result = mysql_query($query) or die ("Couldn't execute query");your query is wrong
should be something like
you may wanna change the execution line to this for a more informative error message
should be something like
Code: Select all
$query = "DELETE FROM news WHERE id=".$idnumber;Code: Select all
$result = mysql_query($query) or die (mysql_error());- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Code: Select all
$query = "DELETE FROM news WHERE id=".intval($idnumber);