Viewing Records
If you verified your work in the preceding section by issuing queries through the MySQL monitor or other interface, you probably became tired of typing SELECT * FROM... for every table. In this section, you'll create the two-part script that shows you how to select and view records in your database.
Listing 18.3 shows the select-and-view script called selentry.php.
Listing 18.3. Script Called selentry.php for Selecting and Viewing a Record
1: <?php 2: //connect to database 3: $conn = mysql_connect("localhost", "joeuser", "somepass") 4: or die(mysql_error()); 5: mysql_select_db("testDB",$conn) or die(mysql_error()); 6: 7: if ($_POST[op] != "view") { 8: //haven't seen the form, so show it 9: $display_block = "<h1>Select an Entry</h1>"; ... |
Get Sams Teach Yourself PHP, MySQL® and Apache All in One now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.