General discussion

  • Creator
  • #2136396

    How to use ADD RECORD and DELETE RECORD in the same form?


    by md2811 ·

    I am learning to create my own database and the sample in my lesson included a form using ADD RECORD which displayed the form at the top of the printed processed data and the DELETE buttons were included at the end of every full entry which was displayed on the same form after the input data. The form example was working perfectly until I tried switching the DELETE button to be included next to the ADD RECORD because I want to include an option to delete a record by the id and have the data displayed in a table below the form. This would be for the administrators entering the data. But I also want the entered records to show in a designed table that will appear on the Website. What I tried did not work. Instead when I moved the array, it just started adding records when clicking on the DELETE. How will I accomplish this?

All Comments

  • Author
    • #2903710

      In what, and it depends. Moved the array.

      by tony hopkinson ·

      In reply to How to use ADD RECORD and DELETE RECORD in the same form?

      Given you’ve displayed the existing records.
      A delete button would normally either be on a each row and pointed at that record.
      Or there would be some means of selecting a record, and the deelet button would do that.

      • #2903693

        For a table…

        by md2811 ·

        In reply to In what, and it depends. Moved the array.

        I want to only have one delete button for a table where a record id can be entered in the input text area to be deleted instead of having the delete for each record. It doesn’t look very attractive in the table. I think it would be best to have it at the end of the table with the option to choose a record to delete. But I just imitated the code that enters a delete button for each row. Therefore, I’m not sure how to manipulate it to just have the option for one delete button for the entire table. The add button is fine where it is.

        • #2903660

          I almost had it….

          by md2811 ·

          In reply to For a table…

          But then something went wrong. I figured out that I can’t have the two buttons, add and delete next to each other because one requires you to enter data which has to have the option to be entered and one requires the data to be displayed that needs to be removed. So I created two forms, one for adding the records and one for displaying and deleting the records (which is originally how I had wanted it). Then I got it to display the way I wanted and the delete was working perfectly, but I couldn’t seem to add any records from the data input form. Then after moving expressions around it got worse! The delete was now deleting all the records instead of just one! Then when I go back into MySQL to re-enter the records, they are not showing as entered even though I got an ok after I INPUT them into the table. So now no records are showing on the delete form. Only the text box and name, delete record button, and the link at the bottom to return to the form where the records are entered. I also can’t seem to use the _END construct anymore like I originally did. It will only accept the echo command for any html input. I can’t seem to figure out where I went wrong.

        • #2903657

          Hard to say from here, but you keep talking about moving the code around

          by tony hopkinson ·

          In reply to I almost had it….

          breaking things, which suggests a standard newbie error.
          View, add, delet and update code should be seperate and independant.

        • #2903646


          by md2811 ·

          In reply to Hard to say from here, but you keep talking about moving the code around

          That is what I did. The form and input codes are separate, but something is not right with the php coding above the form. I’m not using the correct php coding. It was working fine when I had them on the same php form, but then when I separated them into two different forms, I either forgot to add or alter something from when they were on the same form or something else is supposed to be added since they are not on the same form. Although, I do have the form coding separated from each other which it clearly shows the form buttons as they are supposed to be shown. Bottom line is the coding seems to change when they are not on the same form and I can’t seem to figure out the difference in the PHP coding above the form scripts.

        • #2903583

          If you need me to…

          by md2811 ·

          In reply to Confirmed

          I can post the coding if it would make it easier, but only if I know if I can get a response the same day. I’m not having any luck finding the resources that I need to figure this out and I am on a deadline. It would be such a relief to find someone who can give me a solution quickly and I would be much grateful.

        • #2903573

          PHP is not my thing

          by tony hopkinson ·

          In reply to If you need me to…

          You could try Q & A on here, though you might have better luck on StackOverFlow. They’ll want at least enough code to illustrate the problem, and for Ctulhu’s sake be polite and don’t set deadlines and conditions. Like people on here, we help out to be nice. If you want an answer today no matter what, employ someone…

    • #2903709

      Repost as ‘Q&A’

      by charliespencer ·

      In reply to How to use ADD RECORD and DELETE RECORD in the same form?

      Try reposting this in the ‘Q&A’ forum. The ‘Discussion’ forum is for matters of general discussion, not specific problems in search of a solution. The ‘Water Cooler’ is for non-technical discussions. You can submit a question to ‘Q&A’ here:;content

      There are TR members who specifically seek out problems in need of a solution. Although there is some overlap between the forums, you’ll find more of those members in ‘Q&A’ than in ‘Discussions’ or ‘Water Cooler’.

      Be sure to use the voting buttons to provide your feedback. Voting a ‘+’ does not necessarily mean that a given response contained the complete solution to your problem, but that it served to guide you toward it. This is intended to serve as an aid to those who may in the future have a problem similar to yours. If they have a ready source of reference available, perhaps won’t need to repeat questions previously asked and answered. If a post did contain the solution to your problem, you can also close the question by marking the helpful post as “The Answer”.

Viewing 1 reply thread