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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T10:21:55+00:00 2026-06-05T10:21:55+00:00

I have a database loaded with different churches information, I am trying to insert

  • 0

I have a database loaded with different churches information, I am trying to insert all the information from the database into a PHP table with 3 rows.

I would like the structure of each cell to be:

Church Name
Image
Pastor Name

I can easily insert all data into a table, but I cannot get it to display as 3 rows.

echo("<table>");
while($row = mysql_fetch_array($rs))
{
        echo("<tr>");
        echo("<td>");
        echo("<a href='" . $row['website'] . "'>" . $row['churchName'] . "</a><br>");
        echo("<img src=\"" . $row['image'] . "\"><br>");
        echo($row['pastorName'] . "<br><br>");
        echo("</td>");
        echo("<td>");
        echo("<a href='" . $row['website'] . "'>" . $row['churchName'] . "</a><br>");
        echo("<img src=\"" . $row['image'] . "\"><br>");
        echo($row['pastorName'] . "<br><br>");
        echo("</td>");echo("<td>");
        echo("<a href='" . $row['website'] . "'>" . $row['churchName'] . "</a><br>");
        echo("<img src=\"" . $row['image'] . "\"><br>");
        echo($row['pastorName'] . "<br><br>");
        echo("</td>");
        echo("</tr>");

}
echo("</table>");

Doing this causes me to have 3 rows in correct structure, but having duplicate data. I understand that I have not changed the id, but am not sure what I should do

  • 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-05T10:21:56+00:00Added an answer on June 5, 2026 at 10:21 am

    You’re repeating the data on the row. If you want to show 3 items per row, you need to add a counter and a statement to draw the table row breaks, as below:

    $int_Col = 1;
    echo("<table>");
    while($row = mysql_fetch_array($rs))
    {
        if ($int_Col == 1) {
           echo("<tr>");
        }
    
        echo("<td>");
        echo("<a href='" . $row['website'] . "'>" . $row['churchName'] . "</a><br>");
        echo("<img src=\"" . $row['image'] . "\"><br>");
        echo($row['pastorName'] . "<br><br>");
        echo("</td>");
    
        if ($int_Col == 3) { 
            echo("</tr>");
            $int_Col = 1;
        } else {
          $int_Col++;
        }
    }
    
    if ($int_Col > 1) { 
       echo("<td colspan='". (3 - $int_Col) ."'>&nbsp;</td></tr>");
    }
    echo("</table>");
    

    The last check ($int_Col > 1) should ensure the table is rendered properly with an empty cell – should span the correct amount of cells that were not drawn on the current row.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an adjacency list of objects (rows loaded from SQL database with the
I have loaded my database with one table under Data Connections in the Server
I have the following scenario: Entities are loaded from the database. One of them
I have a PHP script that works by calling items from a database based
I have gallery.php that loads images with src path from a database. I also
I have multiple select statements from different tables on the same database. I was
I have a database table as follows: This returns all column titles in the
I'm trying to export data from a multivalue database (Unidata) into MySQL. Lets say
We have a new filestream database that will be initially loaded with 65GB data,
I have an object list being loded from a database to a drop down

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.