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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T00:40:35+00:00 2026-05-14T00:40:35+00:00

I am trying to do the following: <?php foreach($sqlResult as $row): ?> <tr> <?php

  • 0

I am trying to do the following:

<?php foreach($sqlResult as $row): ?>
    <tr>
        <?php foreach($formdata['columns'] as $column): ?>
            <td><?php echo $row->$column['name']; ?></td>
        <?php endforeach; ?>
    </tr>
<?php endforeach; ?>

This does not work.

$row is returned by my mysql query, it has the following : $row->id, $row->author, $row->date, $row->title and these work as they echo fine.

$columns is the following array:

'columns' => array
(
    1 => array
(
    'name' => 'id'
),
    2 => array
(
    'name' => 'author'
),
    3 => array
(
    'name' => 'date'
),
    4 => array
(
    'name' => 'title'
)

it also works fine as $column[‘name’] echoes id, author, date, title

my question is how would it be possible for me to access the $row->method (is it a method?) by passing it a name from the 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-05-14T00:40:35+00:00Added an answer on May 14, 2026 at 12:40 am

    I’m not 100% sure I understand what you want to do but I think you want this:

     <td><?php echo $row->{$column['name']}; ?></td>
    

    notice the curly brackets. They make sure $column["name"] is interpreted fully as the property you want to access. Right now, you are accessing the property named $column and its array key name.

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

Sidebar

Related Questions

This must be really simple... Following examples on here and php.net, I'm trying to
I'm trying the following command in PHP 5.2.12 : print (date('Y-m-d', strtotime('2009-12 last day')));
I am trying the following code: <?php $link = mysql_connect('localhost', 'root', 'geheim'); if (!$link)
Trying to run the following command in php to run powershell command... the following
I am new to PHP and trying to get the following code to work:
I am trying to teach myself MySQL/PHP from the very beginning. The following code
I'm trying use mod_rewrite to rewrite URLs from the following: http://www.site.com/one-two-file.php to http://www.site.com/one/two/file.php The
I'm trying to create css buttons by using the following html markup: <a href=access.php
I have the following smarty code: {foreach from=$additional_fields item=v} {if $v.fieldid eq 5} {php}
PHP Array logic re-factor I'm trying to re-factor my code... This is PHP ...

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.