confused and dazed Posted December 19, 2011 Share Posted December 19, 2011 Hello internet.I am working on a project that will need to allow the user the option to delete information they have submitted. What is the proper way to set up a query that will allow the user to enter a specific piece of information from a specific field to be able to delete that whole row of data? Link to comment Share on other sites More sharing options...
justsomeguy Posted December 19, 2011 Share Posted December 19, 2011 You should show them the data and they click on what they want to delete. Each row needs a unique ID that you pass to the scripts so that they know which row was clicked on. Link to comment Share on other sites More sharing options...
confused and dazed Posted December 19, 2011 Author Share Posted December 19, 2011 Thanks for the initial feedback. It will be important to NOT show the user all the database information. They will need to remember two specific fields they previously entered, enter that data (somehow), and have the sripts delete that whole row. I think by your response that I will need to set up an id for each row - how to best do this? Link to comment Share on other sites More sharing options...
justsomeguy Posted December 19, 2011 Share Posted December 19, 2011 You just need a way to uniquely identify a row. If you have them just typing in values to delete, that may work, but they would be able to delete any row in that table unless you're checking permissions. If those two values are enough to uniquely identify a row then that would work as long as there are no misspellings or things like that. Otherwise, it's most common to use an integer autoincrement ID field for the table to identify each row. In that case you would need to list the rows and have them choose one to delete. If they aren't allowed to see everything, then you need a permission system to determine which rows they are allowed to view and delete. Link to comment Share on other sites More sharing options...
confused and dazed Posted December 19, 2011 Author Share Posted December 19, 2011 After they submit their form an e-mail is sent to their account with all the information they filled out. They will need to take that e-mail (if they cannot remember) and call out the two values. I have set up the insert function to only allow unique names within the form data to be able to be sent to the database. I know that some of the people will know each other so there is another field that I set up in the form (for the user to enter) that is sort of random so that only the user will know it really. So I'm sure I can identify a specific row. I will get to work on the logic code writing now... Link to comment Share on other sites More sharing options...
confused and dazed Posted December 20, 2011 Author Share Posted December 20, 2011 O.K. so I was able to get code to work to take a row out of my database using two specific fields chosen by the user. Now I am having an issue reporting back to the user some statement like "no records matched try again"... this is proving to be difficult. Any suggestions? Link to comment Share on other sites More sharing options...
justsomeguy Posted December 20, 2011 Share Posted December 20, 2011 Do a select query to look up the record before you delete it to check if it exists. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.