Jump to content

[SOLVED] foreach, while, etc.. what to use and how


radar

Recommended Posts

Alright for the life of me i can't figure this out...

 

I've got a table in my database, it's got 2 cells in it they are name and price

 

Now, what I am trying to do is select everything from the database, which is easy.

 

Though I need the output to be something like this.

 

array (

name1 = price1,

name2 = price2,

name3 = price3,

name4 = price4 )

 

with of course the names and prices being whats in the select.  I just have no clue how to do it.

I had figured this out prior to your posting..  it's REAL similar...

 

$prices = mysql_query("SELECT name, price FROM table");

$prices = $aws->sql_prices_array($prices);

 

function sql_prices_array($query1) {

while ($erray = mysql_fetch_array($query1, MYSQL_ASSOC)) {

$mda[$erray["name"]] = $erray["price"];

}

return $mda;

}

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.