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

  • Home
  • SEARCH
  • 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 7601787
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T23:14:55+00:00 2026-05-30T23:14:55+00:00

I am using php to get some data from mysql table. The table returns

  • 0

I am using php to get some data from mysql table. The table returns the right results however because the table has many columns, i thought that i could create a for loop for this and save all my values as val1, val2 etc. I am first using a while loop as there can be several rows:

while($row1 = mysql_fetch_array($sql2)){
    for($i = 1; $i < sizeof($row1); $i++) {
        $val.$i = $row1[$i];
    }

However for some reason sizeof($row1) returns 40 whereas i have only 18 columns in that table.

I think $val.$i = $row1[$i]; is not the right way to declare a variable?

I know i would have made a silly mistake, but i am unable to figure it out. :S

  • 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-30T23:14:57+00:00Added an answer on May 30, 2026 at 11:14 pm

    You’ll want to specify the result type:

    mysql_fetch_array($sql2, MYSQL_NUM);
    

    From the manual:

    By using MYSQL_BOTH (default), you’ll get an array with both
    associative and number indices.

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

Sidebar

Related Questions

I initially create a table using some data loaded from a php mySQL query.
I am using php to get some data from MySQL and displaying it in
I am pulling some data from mysql database using PHP, now I would like
I want to do some innerHTML replacements, but using PHP includes, I dont get
Im using this PHP to get a list of Title's from an RSS feed:
How can i get all the users from the LDAP using PHP. function getUsers()
I have a php page that pulls data from a mysql database based on
I'm currently using mysql w/ PHP because that's what I learned and haven't ever
I'm using a table to save some text data with this structure: CREATE TABLE
I've been using PHP to correlate my HTML table's row ID's with my MySQL

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.