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

  • Home
  • SEARCH
  • 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 8030607
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T00:49:32+00:00 2026-06-05T00:49:32+00:00

I have a small shopping cart I am writing, and currently am facing problems

  • 0

I have a small shopping cart I am writing, and currently am facing problems on how to display MySQL table results into a tabulated display. I have a code that does the whole database search and returns results, my problem is displaying the results like most shopping carts do.

Here is an example of what I would like to achieve.

<table>

<tr>
<td>First mysql result row comes here</td>
<td>Second Mysql result row comes here</td>
</tr>


<tr>
<td>third mysql result row comes here</td>
<td>fourth Mysql result row comes here</td>
</tr>

</table>

Note that it displays two <td> per line.

I am having a tough time trying to find this out. Could it be done using css?

  • 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-06-05T00:49:34+00:00Added an answer on June 5, 2026 at 12:49 am
    <table>
    <?php
    $tr = false;
    
    foreach( $results_from_database as $result ) {
        $tr = !$tr;
    
        if( $tr ) {
            echo '<tr>';
        }
    
        echo "<td>$result</td>";
    
        if( !$tr ) {
            echo '</tr>';
        }
    }
    
    // if there's odd amount of results, add an empty cell and close the tr tag
    if( $tr ) {
        echo '<td></td></tr>';
    }
    ?>
    </table>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a small issue with sessions. I have built a small shopping cart-esque
I will have a 7 small shopping lists and then one big containing all
Have small web page at www.peterbio.com/mom/test.htm Someone wrote the code with mouse over and
I have small problem with simple code. This code is working properly on x86
I have a shopping cart in which I have to keep track of stock,
I am working on ajax module for Shopping cart in Magento. Consider i have
I wrote a small shopping cart in .Net that sends someone to PayPal upon
I'm developing a lightweight shopping cart but have become stumped with products that have
I am looking to implement something that appears to have shopping cart functionality, but
I have code which is creating a XML document for Google Shopping. Google is

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.