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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T13:22:50+00:00 2026-05-24T13:22:50+00:00

I was hoping someone could show how to properly append an array created with

  • 0

I was hoping someone could show how to properly append an array created with an sql query with data from a second query.

I have an array I created from a mysql resource which is correct.

while($row = mysql_fetch_array($result)){
    $first_pass[] = $row; 
} 

But before I finish with the $first_pass array I want to do a second query, so inside the while loop before the $first_pass array I added;

$p = $row['productid'];
$gle = mysql_query("SELECT value FROM `extra_field_values` WHERE productid = $p' AND fieldid ='11' "); 
$goog = mysql_fetch_row($gle);
$row['google_cat'] = $goog[0]; 

my question is, no matter how I add this query to the existing array, when I dump it, it does not look like just another index added to the array. I have tried the mysql_fetch_row with my own created index and I have tried using mysql_fetch_array but then it shows as another array in the array.
I think it will function fine the way it is but it does not look proper.
This is what the dump looks like:

array0
=>array
0 => string ‘3614’ (length=4)
‘variantid’ => string ‘3614’ (length=4)
1 => string ‘1406’ (length=4)
‘productid’ => string ‘1406’ (length=4)
2 => string ‘180-GL-QT-CAY-M’ (length=15)
‘productcode’ => string ‘180-GL-QT-CAY-M’ (length=15)
google_cat => ‘Clothing> Gloves’

where google_cat looks nothing like the rest of the array. So any input is appreciated.
Thanks

  • 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-24T13:22:50+00:00Added an answer on May 24, 2026 at 1:22 pm

    The difference is, your initial $row is populated using mysql_fetch_array() which defaults to using the MYSQL_BOTH fetch method.

    This creates an array using both numeric indices and column name keys.

    When you append your 'google_cat' key, you’re only creating an associative index.

    Unless you’re actually going to use the numeric indices, I’d recommend sticking to mysql_fetch_assoc() instead of mysql_fetch_array()

    Actually, what I really recommend is ditching the mysql extension all together and moving to PDO.

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

Sidebar

Related Questions

HI All I was hoping someone could help me improve a query I have
I was hoping someone could help with a complicated date range SQL query. I
I was hoping someone could help me with this I have data like this
I have the following MySQL query: SELECT Project.*, `trk_deleted`, `trk_status`, `trk_state` FROM `project` AS
I have no idea what's going on here and was hoping someone could help,
I was hoping someone could show me efficient JQuery to animate between 4 background
I am stuck and was hoping someone could help me. I have made a
I have never really done this before so i was hoping that someone could
I have been trying out some LINQ query can someone please show how to
I was hoping someone could help clarify my options regarding refactoring methods from code-behinds

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.