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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T10:36:24+00:00 2026-05-16T10:36:24+00:00

<?php $header = array(‘header1′,’header2′,’header3’); ?> <table> <thead> <tr> <?php for($i=0;$i<=count($header);$i++){?> <th ><?php echo $header[i];?></th>

  • 0
<?php
$header = array('header1','header2','header3');
?>
<table>
<thead>
    <tr>
<?php 
    for($i=0;$i<=count($header);$i++){?>
        <th ><?php echo $header[i];?></th>
    <?php } ?>
    </tr>
</thead>
<?php foreach($result_from_db_query as $key=>$val){?>
 <tr><td><?php echo $val['Column1']?></td><td><?php echo $val['Column2']?></td><td><?php echo $val['Column3']?></td></tr>
?>
</table>
Want to dynamic the row display depend on order of table header
for example if 
$header = array('header1','header2','header3')
the output should like this
<table>
<thead>
    <tr>
        <th >Header 1</th>
        <th >Header 2</th>
        <th >Header 3</th>
    </tr>
</thead>
<tr><td>Column11</td><td>Column21</td><td>Column31</td></tr>
<tr><td>Column12</td><td>Column22</td><td>Column32</td></tr>
<tr><td>Column13</td><td>Column23</td><td>Column33</td></tr>
<tr><td>Column14</td><td>Column24</td><td>Column34</td></tr>
</table>
BUT 
if 
$header = array('header3','header2','header1')

the output should like this

<table>
<thead>
    <tr>
        <th >Header 1</th>
        <th >Header 2</th>
        <th >Header 3</th>
    </tr>
</thead>
<tr><td>Column31</td><td>Column21</td><td>Column11</td></tr>
<tr><td>Column32</td><td>Column22</td><td>Column12</td></tr>
<tr><td>Column33</td><td>Column23</td><td>Column13</td></tr>
<tr><td>Column34</td><td>Column24</td><td>Column14</td></tr>
</table>

And so On.
Anybody know how defind the the data structure with php code.

  • 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-16T10:36:24+00:00Added an answer on May 16, 2026 at 10:36 am
    $header = array('header1','header2','header3');
    
    foreach($result_from_db_query as $val) {
       echo '<tr>';
       foreach($header as $column) { 
          echo '<td>',$val[$column],'</td>';
       }
       echo '</tr>';
    } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Say you have a css files loader style.php : <?php header('Content-type: text/css'); foreach(array('style1.css', 'style2.css',
<?php header('content-type: application/json'); $json = json_encode($data); echo isset($_GET['callback']) ? {$_GET['callback']}($json) : $json; Or should
UPDATED CODE <?php #header( Content-Type: application/xml ); function doLoop($arr = array()) { global $newsStory;
<?php header('Content-type: application/json'); $json = file_get_contents(http://twitter.com/status/user_timeline/lindsaylohan.json?count=1); $temp = json_decode($json); $array = Array(); $array[] =
edit/operacoes.php header('Content-Type: application/json'); include('../../lib/mysql.class.php'); $db = new MySQL(); if($db->Error()) $db->Kill(); //VARIÁVEIS DA FORM $id
I would include a php header ( mysite.com/header.php ) in all the pages from
I have a problem with php header redirect. I already spent hours trying to
Is it possible to append a parameter to a PHP Header Location? I'm having
If I have : domainA.com/out.php : <?php header('location: http://domainB.com/'); ?> Is it possible to
I have created this report using BIRT and phpjavabridge <?php header(Content-type: application/pdf); header(Content-Disposition: inline;

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.