Jump to content

[SOLVED] Get from DB and put into an array


papaface

Recommended Posts

Hello,

Can someone tell me how I can do this.

I want to get the location from the database which i can do:

$getbanners = mysql_query("select location from banners where frequency='{$basis}'");

list($location) = mysql_fetch_array($getbanners);

 

There may be more than one record, therefore how can I put all the locations from the db into one array?

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/47053-solved-get-from-db-and-put-into-an-array/
Share on other sites

Yeah, well considering I asked for help could you explain how to implement that into my setup. Otherwise that doesnt really help me.

edit: You changed it.

 

 

<?php

$MyArray = array();

for($n = 0; $n < $rows; $n++)

{

$mysql_fetch_assoc($n);

$MyArray[] = rows['TheData'];

}

 

?>

But what you posted wont work.

I am here to help not to write the whole thing for you, their are many sections

if you don't know how to use MySql with PHP you could of just asked

 

what i posted was an example (which i updated to as it included some OOP)

 

anyways good luck and good day

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.