PHP SOLUTIONS: DYNAMIC WEB DESIGN MADE EASY 3. (Web design programs)
PHP SOLUTIONS: DYNAMIC WEB DESIGN MADE EASY 3. To show all the thumbnails, you need to wrap the table cell in a loop. Insert a new line after the XHTML comment about repeating the row, and create the first half of a do… while loop like this (see Chapter 3 for details of the different types of loops): 4. You already have the details of the first record in the result set, so the code to get subsequent records needs to go after the closing
tag. Create some space between the closing
and
tags, and insert the following code. It s slightly different for each method of database connection. For the MySQL original extensions, use this:
For the MySQL Improved object-oriented interface, use this:
fetch_assoc(); } while ($row); ?>
For PDO, use this:
fetch(); } while ($row); ?>
This fetches the next row in the result set and sends the loop back to the top. Because $row[’filename’] and $row[’caption’] have different values, the next thumbnail and its associated alt text are inserted into a new table cell. The query string is also updated with the new filename. 5. Save the page, and test it in a browser. You should now see all eight thumbnails in a single row across the top of the gallery, as shown at the top of the next page. Hover your mouse pointer over each thumbnail, and you should see the query string display the name of the file. You can check your code against gallery_mysql04.php, gallery_mysqli04.php, or gallery_pdo04.php.
Searching for affordable and reliable webhost to host and run your web applications? Go to our java web server services and you will be pleased.