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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T02:51:08+00:00 2026-06-11T02:51:08+00:00

Been researching this for an hour. I give up. I’m trying to create an

  • 0

Been researching this for an hour. I give up. I’m trying to create an array after populating the array from a MySQL table.

I then want to output the array text elements across the top of a table (table headings)

$sqlRotations="SELECT id, rotationName FROM sched_rotations";
$resultRotations=mysql_query($sqlRotations);
$arrayRotations = array();
while($row_Rotation=mysql_fetch_assoc($resultRotations)){ 
  $arrayRotations[]=$row_Rotation;
} 

…then I’m trying to print out the “rotationName” as table column headings:

<table>
<tr>
<?
foreach( $arrayRotations as $key => $value){
echo "<td>Id: $key, Rotation:". $arrayRotations[$value]." </td>";
}
?>
</tr>

Unfortunately, this gives me the following output in < t d > format:

Id: 0, Rotation: Id: 1, Rotation: Id: 2, Rotation: Id: 3, Rotation: Id: 4, Rotation: Id: 5, Rotation: Id: 6, Rotation: Id: 7, Rotation: Id: 8, Rotation: Id: 9, Rotation: Id: 10, Rotation:


Furthermore if I change the for key value echo to this:

foreach( $arrayRotations as $key => $value){
echo "<td>Id: $key, Rotation:". $value." </td>";

}

then I get this output:

Id: 0, Rotation:Array Id: 1, Rotation:Array Id: 2, Rotation:Array Id: 3, Rotation:Array Id: 4, Rotation:Array Id: 5, Rotation:Array Id: 6, Rotation:Array Id: 7, Rotation:Array Id: 8, Rotation:Array Id: 9, Rotation:Array Id: 10, Rotation:Array

  • 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-11T02:51:10+00:00Added an answer on June 11, 2026 at 2:51 am

    Is this what you are looking for?

    <table>
    <tr>
    <th>Id</th>
    <th>Rotation</th>
    </tr>
    <?php 
    foreach($arrayRotations as $rotation)
    {
       printf("<tr><td>%s</td> <td>%s</td></tr>", $rotation['id'], $rotation['rotationName');
    }
    ?>
    </table>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been researching this for a while but got no convinced answer. From
I've been researching this for the last 2 days after I implemented my own
I've been researching all over for this, basically I have a table that displays
Hopefully, someone here can give me some light. I have been researching this issue
I've been researching this, but i wanted some input from the community in regards
I've been researching this and trying many variations based off my understanding of how
I have been researching this issue pretty extensively and cannot seem to find an
I've been researching this problem, but I can't find what I need. It shouldn't
I've been researching this for a couple of days and I'm seing a lot
I have been researching this for a few hours and I feel that I

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.