Jump to content

More Fun With Arrays


phpretard

Recommended Posts

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

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.