phpretard Posted May 9, 2008 Share Posted May 9, 2008 I would like to setup an Array from a database for a pricing structure. Thanks to the wonderfully selfless people in this forum I have a much better understanding of arrays. THANK YOU ALL! $sql = "SELECT * from pricing"; $result = mysql_query($sql,$con); while ($property = mysql_fetch_field($result)) { $price[$property ->name]=$name; } print_r($price); The Above Gives Me The Field Values: Array ( [id] => [Postcards] => [brochures] => [Car Door Magnets] => [Rack Cards] => [Flyers] => [Folders] => [Magnets] => [Hats] => [T-Shirts] => [Pens] => [Tri-Fold Brochure] => [Door Hangers] => ) The array below I just filled in manually to demenstrate my objective. The dollor amounts you see are the values in the database fields. My problem is I can't get them to show up in the array. Array ( [id] => 1 [Postcards] => 10.00 [brochures] => 25.00 [Car Door Magnets] => 36.00 [Rack Cards] => 60.00 [Flyers] => 50.00 [Folders] => 30.00 [Magnets] => 5.00 [Hats] => 15.00 [T-Shirts] => 20.00 [Pens] => 1.00 [Tri-Fold Brochure] => 65.00 [Door Hangers] => 25.00) PS If you know of a better wat to set up a database that contains products and pricing I am open for suggestions. Link to comment https://forums.phpfreaks.com/topic/104796-more-fun-with-arrays/ Share on other sites More sharing options...
maxudaskin Posted May 9, 2008 Share Posted May 9, 2008 Array( [0] Postcard [0] 2.99 [1] Book [0] 7.99 [2] Compact Disc [0] 12.99 ) Link to comment https://forums.phpfreaks.com/topic/104796-more-fun-with-arrays/#findComment-536462 Share on other sites More sharing options...
sasa Posted May 9, 2008 Share Posted May 9, 2008 ... while ($property = mysql_fetch_assoc($result)) { $price[]=$property; } print_r($price); Link to comment https://forums.phpfreaks.com/topic/104796-more-fun-with-arrays/#findComment-536506 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.