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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T15:35:59+00:00 2026-06-10T15:35:59+00:00

I have a database with structure TableName | Row1 | Row2 | Row3 …etc

  • 0

I have a database with structure

TableName | Row1 | Row2 | Row3 ...etc

My ‘Row’ table column goes up quite high, I wanted to try to query the database and use a variable in the row name to return my value, except it keeps returning NULL values, probably because it isn’t actually returning anything

<?php
    $connection = mysqli_connect(....);

    $sql = "SELECT * FROM table";
    $result = $connection->query($sql);
    if($result) {
        while($row = $result->fetch_object()) {
            for($i = 1; $i < 5; $i++) {
                echo $row->Row.$i;
            }
        }
    }
?>

I thought this would be the code but it doesnt work like this, currently I have the code set to

for(...
    $myrow = 'Row'.$i;
    echo $row->$myrow;
}

Which works although its a little sloppy and I assume there is a much nicer way of doing it

  • 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-10T15:36:00+00:00Added an answer on June 10, 2026 at 3:36 pm

    Perhaps this is what you mean:

    $row->{'Row'.$i};
    

    Not sure if I understood the question correctly, though,

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

Sidebar

Related Questions

I have a mysql database with a table structure like below : Table Name
I have this database structure, SET SQL_MODE=NO_AUTO_VALUE_ON_ZERO; CREATE TABLE IF NOT EXISTS `announces` (
I have mysql database structure like below: CREATE TABLE test ( id int(11) NOT
I have an XML structure like the following: <tables> <table name=tableName1> <row ID=34 col1=data
I have the following database structure: Sites table id | name | other_fields Backups
I have database structure as User Table(user id, username, first name,last name) Event Table(event
In my MySQL database, I have a table with structure username - varchar insert_time
I have the following database structure: CREATE TABLE `author` ( `id` int(10) unsigned NOT
I have such database structure (1 - one, 0 - many) Product 1->0 Orders
let's say I have a database structure like below: Students +--------------+--------------------+-------------------+ | student_id |

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.