Jump to content

[SOLVED] Inserting data from a sql database into an array


johng

Recommended Posts

I am currently working on a project where I need to put information from a sql statement into an array.  Currently I can get one row into the array, but the rest aren't showing.  I have checked, and all of the information is getting to the array, but I can only get one row to show up. 

 

Here's the code:

 

  while(($row = mysql_fetch_array($result)))
  {
   $info=array($count=>array('line1'=>$row["first_name"], 'line2'=>$row["last_name"], 'line3'=>$row["product"], 'line4'=>"\$".$row["date"]));
   $count++;
  }

 

I'm trying to get this array to hold multiple rows from the sql statement, but when I display the array, I can only get one row out of it. Any help on this would be much appreciated.

 

 

As always, thanks in advance!

Link to comment
Share on other sites

The main reason I used 'line1', 'line2', etc. is because it was being fed into another function, and that function was set up to use those field names.  Basically it was way less complicated because I didn't want to fiddle with the other function.  But thanks for the extra info!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.