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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T07:00:35+00:00 2026-06-04T07:00:35+00:00

I found an example here that shows an example like this: <?php for ($i

  • 0

I found an example here that shows an example like this:

<?php 
for ($i = 1; $i <= 5; $i++) {
  ${a.$i} = "value";
}    

echo "$a1, $a2, $a3, $a4, $a5";
//Output is value, value, value, value, value
?>

Is it possible to modify it to work like this:

for($x=1; $x<11; $x++)
{
    ${title.$x} = $row['${title.$x}'];
    ${brief.$x} = $row['${brief.$x}'];
    ${cost.$x} = $row['${cost.$x}'];

    echo "<tr>
               <td>${title.$x}</td>
          </tr>
          <tr>
               <td>${brief.$x}</td>
          </tr>
         ";
 }

The $row array comes from a mysql query.

  • 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-04T07:00:35+00:00Added an answer on June 4, 2026 at 7:00 am
    for($x=1; $x<11; $x++)
    {
        ${'title'.$x} = $row['title'.$x]; // will be like: $title1 = $row['title1']; (if you mean that)
        ${'brief'.$x} = $row['brief'.$x];
        ${'cost'.$x} = $row['cost'.$x];
    
        echo "<tr>
                   <td>${'title'.$x}</td>
              </tr>
              <tr>
                   <td>${'brief'.$x}</td>
              </tr>
             ";
     }
    

    If your variable name is same with the key name in the $row, you could use extract($row) to get all variables you want.

    But in your case, I think using the $row array directly is not bad idea.

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

Sidebar

Related Questions

I'm trying to follow the Auth example for Webapp2 that can be found here:
like in this post here by exemple I have found this blog but in
I have a site that currently serves results as example.com/index.php?show=foo and I'd like it
I know this seems like I should have immediately found the one example out
I'm so close! I'm using the XNA Game State Management example found here and
I found a great C++/ODBC example here ... The project I downloaded builds great
I am using the jQuery spinner tool found here: http://btburnett.com/spinner/example/example.html When I try using
I found this example and used it How do you resize a Bitmap under
I found this example in the App Engine documentation . 1 <% 2 UserService
I'm trying to parse a file that looks like this: || Column Header A

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.