Jump to content
Larry Ullman's Book Forums

Search the Community

Showing results for tags 'while loop'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Single Editions
    • Modern Javascript: Develop and Design
    • The Yii Book
    • Effortless Flex 4 Development
    • Building a Web Site with Ajax: Visual QuickProject
    • Ruby: Visual QuickStart Guide
    • C++ Programming: Visual QuickStart Guide
    • C Programming: Visual QuickStart Guide
    • Adobe AIR: Visual QuickPro Guide
  • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (5th Edition)
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (4th Edition)
    • PHP 6 and MySQL 5 for Dynamic Web Sites: Visual QuickPro Guide (3rd Edition)
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (2nd Edition)
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (1st Edition)
  • PHP for the Web: Visual QuickStart Guide
    • PHP for the Web: Visual QuickStart Guide (5th Edition)
    • PHP for the Web: Visual QuickStart Guide (4th Edition)
    • PHP for the Web: Visual QuickStart Guide (3rd Edition)
    • PHP for the World Wide Web: Visual QuickStart Guide (2nd Edition)
    • PHP for the World Wide Web: Visual QuickStart Guide (1st Edition)
  • Effortless E-commerce with PHP and MySQL
    • Effortless E-Commerce with PHP and MySQL (2nd Edition)
    • Effortless E-Commerce with PHP and MySQL
  • PHP Advanced: Visual QuickPro Guide
    • PHP Advanced and Object-Oriented Programming: Visual QuickPro Guide (3rd Edition)
    • PHP 5 Advanced: Visual QuickPro Guide (2nd Edition)
    • PHP Advanced: Visual QuickPro Guide
  • MySQL: Visual QuickStart Guide
    • MySQL: Visual QuickStart Guide (2nd Edition)
    • MySQL: Visual QuickStart Guide (1st Edition)
  • Other
    • Announcements
    • Newsletter, Blog, and Other Topics
    • Forum Issues
    • Social

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Found 2 results

  1. I'm trying to build an online tool checkout application, so I'm working with script 10.5 to pull (tool names) from a database to populate a table. I need to be able to select multiple tools (using checkboxes), and then submit that form to a shopping cart. I've been able to add a checkbox to each result, but is this the correct way to give each checkbox the name associated with it? // Fetch and print all the records.... $bg = '#eeeeee'; while ($row = mysqli_fetch_array($r, MYSQLI_ASSOC)) { $bg = ($bg=='#eeeeee' ? '#ffffff' : '#eeeeee'); echo '<tr bgcolor="' . $bg . '"> <td align="left">' . $row['category'] . '</td> <td align="left">' . $row['name'] . '</td> <td align="left"> <form action="view_cart.php" method="post"> <input type="checkbox" name="checked" value="$row['name']" /> </td> '; } // End of WHILE loop. And then to display the results? if ($_SERVER['REQUEST_METHOD'] == 'POST') { while ($row = mysqli_fetch_array ($r, MYSQLI_ASSOC)) { echo "\t<tr> <td align=\"left\">{$row['name']}</td> </tr>\n"; } // End of the WHILE loop. It just feels like a shot in the dark, and so I wanted to ask.
  2. Hi Larry, great book, finding it really clear and useful. Thought I'd just ask about the style of coding you've used to display the products in the list_products.html file. You include the header div for that page within the while loop, only echoing it on the first iteration. It uses the g_description and g_image columns from the first row. My problem is that, g_description and g_image are still in every other row of the mysql result. They are identical to those in the first row and are never used. I can't help but feel it's a shame to have called for them in the first place. Have you done it this way to minimize calls to the database? The way I might be tempted to write this page, is to get the category details in a separate database call, then I could take the header completely out of the while loop, and there wouldn't be a need for the if (!$header){ condition. Hope that makes sense to you. Just wondering what your thoughts on this were? Thanks for reading!
×
×
  • Create New...