Jump to content

Recommended Posts

alright. to get right to the point. i need results in an array....

 

i have tryed

 

$result = mysql_query("SELECT * FROM table");
while($mfa = mysql_fetch_array($result)) {

$array = array($mfa['field_name']);

}

echo $array[1];

#########################################

but that just returns the word Array

 

i have also try to explode and implode results...

it would be helpful if anyone could provide a code or helpful information :)

 

Thanks,

Mike

 

Link to comment
https://forums.phpfreaks.com/topic/83074-putting-mysql-results-into-an-array/
Share on other sites

Also if you want the array keys to be the name of the database field use this:

 

$query = "SELECT `var1`, `var2` ....";
$run = mysql_query($query);
while($arr = mysql_fetch_assoc($run)){
    extract($arr); // Takes each database field and makes it as it's own php variable
    echo "var = $var1, var2 = $var2 <br />";
}

Thanks you guys..

 

Northern Flame's reply was what I was looking for... along with some tweaking of my own. :)

 

revraz, i didn't really get how to echo each as a seperate name.. they were all Array[0]

 

and p2grace.. your way was nice as well.. but wasn't what i was looking for.

 

 

thanks for taking the time to help :)

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.