Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7634833
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T07:16:58+00:00 2026-05-31T07:16:58+00:00

I’ve created a product catalogue in PHP, I want the products to come up

  • 0

I’ve created a product catalogue in PHP, I want the products to come up as a table like in a grid, so it has 3 products on one row side by side, then carries on underneath and so on. I’ve got it so the products repeat horizontally, I just don’t know how to make it automatically start a new line after three products..

Here’s my code currently:

<?php # Script 17.5 - browse_prints.php
// This page displays the available prints (products).

// Set the page title and include the HTML header:
$page_title = 'Browse the Films';

require_once ('mysqli_connect.php');

// Default query for this page:
$q = "SELECT image_name, genre.genre_id, CONCAT_WS(' ', genre_name) AS genre, film_name, price, platform, description, film_id, image_name FROM genre, film WHERE genre.genre_id = film.genre_id AND film.platform = 'DVD' ORDER BY genre.genre_name ASC, film.film_name ASC ";

// Are we looking at a particular genre?
if (isset($_GET['gid']) && is_numeric($_GET['gid']) ) {
$gid = (int) $_GET['gid'];
if ($gid > 0) { // Overwrite the query:
    $q = "SELECT image_name, genre.genre_id, CONCAT_WS(' ', genre_name) AS genre, film_name, price, description, film_id, image_name FROM genre, film WHERE genre.genre_id = film.genre_id AND film.genre_id = $gid AND film.platform = 'DVD' ORDER BY film.film_name";
}
}



// Create the table head:
echo '<table border="0" width="90%" cellspacing="3" cellpadding="3" align="center">
<tr>
    <td align="left" width="50%"><b>Film Name</b></td>
    <td align="right" width="50%"><b>Price</b></td>
</tr><tr>';


// Display all the prints, linked to URLs:
$r = mysqli_query ($dbc, $q);
while ($row = mysqli_fetch_array ($r, MYSQLI_ASSOC)) {

// Display each record:
//image
$image_name = $row['image_name'];
echo "
    <td><a href=\"view_print.php?fid={$row['film_id']}\">{$row['film_name']}<br><br>
    <img src=uploads/$image_name.jpg><br>
    <br>&#163;{$row['price']}</td>
";


} // End of while loop.

echo '</tr></table>';
mysqli_close($dbc);

?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T07:17:00+00:00Added an answer on May 31, 2026 at 7:17 am

    div are better solutions than tables.
    But if you want to do that, add a counter.

    // Create the table head:
    echo '<table border="0" width="90%" cellspacing="3" cellpadding="3" align="center">
    <tr>
        <td align="left" width="50%"><b>Film Name</b></td>
        <td align="right" width="50%"><b>Price</b></td>
    </tr>';
    
    $row_count = 0:
    // Display all the prints, linked to URLs:
    $r = mysqli_query ($dbc, $q);
    while ($row = mysqli_fetch_array ($r, MYSQLI_ASSOC)) {
    $row_count++;
    if ($row_count==1) echo "<tr>";
    // Display each record:
    //image
    $image_name = $row['image_name'];
    echo "
        <td><a href=\"view_print.php?fid={$row['film_id']}\">{$row['film_name']}<br><br>
        <img src=uploads/$image_name.jpg><br>
        <br>&#163;{$row['price']}</td>
    ";
        if ($row_count==3) {
             echo "</tr>";
             $row_count=0;
        }
    } // End of while loop.
    
    if ($row_count>0) echo "</tr>";
    echo '</table>';
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I would like to count the length of a string with PHP. The string
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.