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 7805735
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T02:18:37+00:00 2026-06-02T02:18:37+00:00

EDIT: This is what I am trying to achieve: https://i.stack.imgur.com/QJD2Z.png I am trying to

  • 0

EDIT: This is what I am trying to achieve: https://i.stack.imgur.com/QJD2Z.png

I am trying to display the results from my database in two columns. I’m a bit new to PHP so I haven’t the slightest clue on how to do this. Can anybody help me with this? Thanks in advance.

Here is my current code:

include('connect.db.php'); 
// get the records from the database
if ($result = $mysqli->query("SELECT * FROM todo ORDER BY id"))
{
  // display records if there are records to display
  if ($result->num_rows > 0)
  { 
    // display records in a table
    echo "<table width='415' cellpadding='0' cellspacing='0'>";
    // set table headers
    echo "<tr><td><img src='media/title_projectname.png' alt='Project Name' /></td>
        <td><img src='media/title_status.png' alt='Status'/></td>
      </tr>";
    echo "<tr>
        <td><div class='tpush'></div></td>
        <td>&nbsp;</td>
      </tr>"
    while ($row = $result->fetch_object())
    {
      echo "<tr>";
      echo "<td><a href='records.php?id=" . $row->id . "'>" . $row->item . "</a></td>";
      echo "<td>" . $row->priority . "</td>";
      echo "</tr>";
    }
    echo "</table>";
  }
  // if there are no records in the database, display an alert message
  else
  {
    echo "No results to display!";
  }
}
// show an error if there is an issue with the database query
else
{
   echo "Error: " . $mysqli->error;
}
// close database connection
$mysqli->close();
  • 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-02T02:18:38+00:00Added an answer on June 2, 2026 at 2:18 am

    A good idea would be storing your data into a simple array and then display them in a 2-columned table like this:

    $con = mysql_connect('$myhost', '$myusername', '$mypassword') or die('Error: ' . mysql_error());
    mysql_select_db("mydatabase", $con);
    mysql_query("SET NAMES 'utf8'", $con);
    
    $q = "Your MySQL query goes here...";
    $query = mysql_query($q) or die("Error: " . mysql_error());
    $rows = array();
    $i=0;
    
    // Put results in an array
    while($r = mysql_fetch_assoc($query)) {
        $rows[] = $r;
        $i++;
    }
    
    //display results in a table of 2 columns
    
    echo "<table>";
    for ($j=0; $j<$i; $j=$j+2)
    {
    echo "<tr>";
    echo "<td>".$row[$j]."</td><td>".$row[$j+1]."</td>";
    echo "</tr>";
    }
    echo "</table>";
    
    mysql_close($con);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Edit: I put this snippet of code in jsbin: http://jsbin.com/eneru I am trying to
I'm trying to enter edit mode on a specific cell like this: void MainWindow::on_addButton_released()
I'm trying to get edit text to behave in this way: User can input
Greetings, for one of my applications I'm trying to implement an Edit menu. This
I am trying to see if its possible to achieve this kind of shadow
Here is what I am trying to achieve in PHP: I have this string:
Basically this is what I am trying to achieve. classname@address(?)[original toString() ], object's name,
I'm trying to achieve a basic fixed table header effect. For this I'm using
EDIT: This post was originally specific to ASP.NET, but after thinking about it I'm
Edit This question has gone through a few iterations by now, so feel free

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.