Simple PHP help please help its driving me nuts!?

  • Thread starter Thread starter Cazpa
  • Start date Start date
C

Cazpa

Guest
Hi

I have got this script that deletes rows from a database, I have edited it so that it only shows and allows a user to delete thier own record.

anyway, the script pulls the data ok and displays it and all works up until the point you click delete... It deletes all the records (multiple rows) rather than just the one clicked.

I am no good with Javascript and I am wondering if anyone can see where I am going wrong.

The source code can be found here: http://www.essex-atw.com/help.txt

its probably a quick fix and if you need to know anymore, please let me know.

Thanks in advance
Hi Thanks everyone

I have fixed it (I think)

DELETE FROM user_scripts WHERE id = '{$_GET['delnews']}'
Hi Brindy

Yes, what happens is the user submits information and I use the session variable as a hidden feild, the only info that a user ever seens is thier own info. thisis all stored on a seperate table, they dont edit anything from the session in this case. Its just a way to manage the user submission.
 
Here's the error:

WHERE user = '{$_SESSION['user']}'"

Everytime you clicked an item, it will delete ALL items that the USER created. You didn't specify which item.

If you wanna delete the item you clicked you can use the items id or primary key. Like this:

DELETE from Table_name WHERE Table_id='.$item_id.'

Table_id should be the ID or Primary key of your table.

Hope that helps =)
 
Back
Top