Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to design search and update functionality in PHP (and pass data from page to page)?
    primarykey
    data
    text
    <p>This question may have been asked before, but I cannot find the answer. I apologize in advance for possibly re-asking a question.</p> <p>What is the appropriate way to design search and update functionality in PHP - to search for records that meet user criteria, select a specific record, and update data on that record?</p> <p>This is a user account based system (so users register and create an account). MySQL is the database on the back-end. Users are able to create content, search for content, edit their own content, and delete their own content.</p> <p>I see there being three pages:</p> <p>Page 1. Search page - on this page, the user will key in for what they are searching</p> <p>When the user activates the "Search" button, the form would do some processing to ensure the input was valid / all the fields were filled out, etc.</p> <p>Page 2. Results page - on this page, the results of the search criteria would be displayed</p> <p>Next to each result would be a button or hyperlink to allow the user to edit the content</p> <p>Page 3. Edit page - on this page, the selected record would be displayed and the user could edit the content, e.g. change comments, change values, etc.</p> <p>I think this 3 page format is fairly standard. What I don't know is what is the appropriate way to pass data from page to page, and how and when to execute SQL SELECT statements?</p> <p>On Page 1, the user hits "Search", the form does some validation, and if everything passes validation, then the search criteria should be passed to Page 2 through the URL? Is that the appropriate way?</p> <p>On Page 2, a SQL SELECT is executed searching for rows that meet the input criteria. Rows that match the input criteria are displayed. The user selects a record and activates the hyperlink. Does the hyperlink pass the record_id of the selected record to Page 3 through the URL? Is that the appropriate way?</p> <p>Then on Page 3, another SQL SELECT is performed, this time for the specific record that was selected. Is that the appropriate way?</p> <p>To summarize:</p> <p>1) Is it appropriate to pass query criteria from search page to result page via the URL?</p> <p>2) Is it appropriate to pass the record_id of the record to be edited from results page to edit page via the URL?</p> <p>3) Is it appropriate to perform 2 SQL SELECTS during this process: 1 SQL SELECT on the results page to select all records that matched the search criteria, and 1 SQL SELECT on the edit page to display the attributes of the record to be edited.</p> <p>I know there are "a million different ways" to accomplish tasks through computer programs. That is one of the aspects of computer programming and design which I like - the creativity a programmer is able to use to solve problems. That said, is the approach (design pattern) I laid out above appropriate? Are there serious flaws with that design pattern? Is there a generally recognized "better way" to do it?</p> <p>Thanks for reading.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload