Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
Once you've created a list page and data entry forms for inserting and updating data, you can then tie the whole thing together by adding hyperlinks to the list page. The user will be able to click the links to navigate to the forms. I'll start this demonstation in the file explorerlist.php, in the explorers folder of the site. Looking at the file in Design View, I'll click on the Live View button and show that the page is successfully retrieving and displaying data from MySQL. I'll exit Live View and then click to the right of the HTML table, and I'll press Enter or Return to create a new paragraph.
Then I'll type some text that the user will be able to click on to navigate to the insert form. I'll type the text Insert New Explorer. Then I'll select that new text and go to the Properties panel. I'll make sure that the HTML category is selected and then I'll create the hyperlink using either the Point to File or the Browse for File tools. For this demonstration, I'll use Point to File. Make sure that the file you want to link to is visible in the Files panel. I'll be linking to the prebuilt form, explorerinsert2.php.
Click and drag the Point to File tool and drop it onto the target file. That creates the hyperlink. Then I'll save and run the page in an external browser. If you followed these steps and you're prompted to copy the file to the testing server, say Yes. In the page in the browser, here's my new link. I'll click that link and that takes me to the insert form. And then I'll type some values. I'll set the first name to New and the last name to Explorer.
I'll set the date of birth to 12/23/1996. I'll set the e-mail address of new@ explorer.com, I'll leave the address and city blank and I'll set the state to California. I'll click Submit, and that causes the form to navigate back to the list page and I'll see that my new data has been inserted into the database successfully. So an insert hyperlink is very simple. You're just navigating to the form that's going to do the insertion, and then in the form's insert logic, you're navigating back to the list page after the data's been added to the database.
Editing data is a little bit more complex. You'll need to add a hyperlink to each row of the dynamic HTML table. You can either create a new column and create hyperlinks on a particular word like Edit, or you can create hyperlinks on existing data, such as the first name. That's what I'll do. I'll go back to Dreamweaver and then I'll click on the first name column of the rsExplorers record set. You only need to click on this value; you don't need to double- click and you don't need to drag.
Then with the value selected, I'll go down to the Properties panel, just like I did for the insert link and this time I'll use the Browse tool. I'll click Browse for File, in the correct site root. In this case it should be 07_managingdata. Then drill down to the explorers folder and choose the prebuilt version of the update form, explorerupdate2.php. So that added a simple hyperlink to the selected text. But you can actually add logic to pass a variable very easily from the Browse dialog.
I'll click the Browse button again and then down toward the bottom of the dialog I'll click the P arameters button. In the Parameters button you add an name and a value for each value that you want to pass to the update form. You must pass the primary key value to the update form so that it knows which record to display. I'll set the name of the parameter to explorerid, all lowercase. Then I'll click in the Value column and click the lightning bolt and then if it's not already open I'll open up the record set tree, and I'll choose the primary key column explorerId.
I'll click OK, click OK again, and click OK a third time. Then I'll go to Code View and show you the resulting generated code. The HREF attribute starts with the name of the file I'm navigating to and then after a question mark passes the variable named explorerid and sets its value to the column explorerId. Now one very important thing that you have to check is that because PHP variables are case-sensitive, you must make sure that the variable that you pass from this page matches the spelling of the variable you're expecting in the target page.
So now I'll go to the Diles panel and open explorerupdate2.php, and make sure you're looking at it in Code View. Then scroll down in the file to lines 69 through 71. This code was generated by Dreamweaver. Notice that in Dreamweaver it matches the name of the variable to the name of the database column. And if your database column has any uppercase characters, it uses those. I usually like to set all my variables with all lowercase. So to make sure that the two match, in the isset function I'll set explored to all lowercase there.
And then I'll do the same thing on the next line. So now the spelling of the variable in the target file exactly matches the stone of the variable in the sending file. I'll save my changes in both files and then just to be sure that they've both been copied to the server, I'll go to explorerupdate2.php and look at it in Live View. It'll open up to default record, that is, the record with a primary key value of one. Then I'll exit Live View and I'll go to explorerlists.php and I'll open this file in the browser.
Now I should be able to click on any link, and I should see this selected record. I'll click on New for New Explorer. And when the form opens it shows me that record. I'll set the first name value from New to Revised and I'll click Submit. And when the form's logic is completed I'm sent back to the list. And I'll see that the data has been revised. I'll also use this opportunity to fix the first row of my data, which I had a problem with in a previous exercise.
I'll click on Joey in Joey Adams and I'll set the date of birth to 4/15/1993. I'll click Submit, and when I return to the list page, I see the data correctly display. So that's a look at how to tie the components of the data management system together. From the list page you put in a simple hyperlink that takes you to the insert form and you also add in a dynamic URL for each record that passes a query string or a GET variable to the update form.
The update form then displays the existing data, the user can make whatever changes are required, and then when they submit the changes they're saved to the database.
Get unlimited access to all courses for just $25/month.Become a member
82 Video lessons · 86703 Viewers
80 Video lessons · 136004 Viewers
59 Video lessons · 54733 Viewers
52 Video lessons · 68628 Viewers
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.