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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T21:31:44+00:00 2026-06-11T21:31:44+00:00

I need my PHP page to show the following structure: <table border=1> <tr> <td>Title

  • 0

I need my PHP page to show the following structure:

  <table border="1">
  <tr>
         <td>Title one</td><td>Title two</td>
  </tr>
  <tr>
         <td>I'm content one</td><td>And here's content two</td>
  </tr>
  </table>

And here’s my php page:

$array = array( array( Title => "Title one"), array( Title => "Title two") );
$array2 = array( array( Content => "I'm content one"), array( Content => "And here's content two") );
 $myvar ="Title one";

$htm .="<table border='1'>";
    for ($i=0; $i<=1; $i++) 
    {
        $htm .="<tr>";
        foreach ($array[$i] as $title)
        {   
            $htm .="<td >".$title."</td>"; 
            foreach($array2 as $b)
            {
                $content  = $b['Content'];
                    if ($myvar == $title)
                    {
                        $htm .="<tr><td>".$content."</td></tr>"; 
                    }else
                    {
                        $htm .="<tr><td ></td></tr>"; 
                    }

            } 
        }
    }

$htm .="</table>";
echo $htm;

Which is outputting:

<table border='1'>
<tr>
<td >Title one</td><tr><td>I'm content one</td>
</tr>
<tr>
<td>And here's content two</td></tr>
<tr><td >Title two</td><tr>
<td></td></tr><tr><td ></td></tr>
</table>

How can I modify the html outputs to get the structure I need?

  • 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-11T21:31:45+00:00Added an answer on June 11, 2026 at 9:31 pm

    Try this code, I hope this is what you want:

    $array = array( array( Title => "Title one"), array( Title => "Title two") );
    $array2 = array( array( Content => "I'm content one"), array( Content => "And here's content two") );
    
    $htm .="<table border='1'>";
        for ($i=0; $i<=1; $i++) 
        {
            $htm .="<tr>";
            foreach ($array[$i] as $title)
            {   
                $htm .="<td >".$title."</td>"; 
                $j=0;
                foreach($array2 as $b)
                {
    
                    $content  = $b['Content'];
                        if ($j == $i)
                        {
                            $htm .="<td>".$content."</td></tr>"; 
                        }
                        $j++;
    
                } 
            }
        }
    
    $htm .="</table>";
    echo $htm;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following link structure for my portfolio: <?php echo $this->Html->link($post['Portfolio']['title'], array('controller' =>
I develop a php web page that contains two dropdownlists (select tags) as one
I am implementing search page in php. I need to show the results like
I have a PHP page I need to limit execution access of to only
I need to start a Unix process by calling a PHP-page through the web.
I have a php page inside a folder on my website. I need to
I need to redirect all page requests (php, if that matters) on a specific
I need to redirect user to another page called free.php from index page, if
How to create simple PHP COMET server page displaying current time? I need code
I need a solution for caching PHP info on a dynamic page AND include

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.