RE: [PHP-DB] Re: Array help needed :-(

2002-10-08 Thread Simon Taylor

You may want to revisit your db design, but if it is like that for  reason
then it is simple enough to associate these items with each other in an
array.
Just put together a query then get the row and split it by the commas then
put it into an array as follows.
$ar = Array('small' = '1.99', 'medium' = '2.99', 'large' = '3,99');
Then you can access these values by the following.

$smvalue = $ar['small']

This example is a simple array, if you had a lot of products you could use a
multi dimensional array like this.

$ar = Array( 'hotdogs' = Array('small' = '1.99', 'medium' = '2.99',
'large' = '3,99'), 
 'burgers' = Array('small' = '2.99', 'medium' = '4.99',
'large' = '6,99'))

Then access them like this

$smallburger = $ar['burger']['small']

Hope this helps.
Simon

-Original Message-
From: David Robley [mailto:[EMAIL PROTECTED]] 
Sent: 8 October 2002 06:49
To: [EMAIL PROTECTED]
Subject: [PHP-DB] Re: Array help needed :-(


In article 000801c26e10$a2128510$f7fea8c0@chris, [EMAIL PROTECTED] 
says...
 Hi there everyone,
 
 I have a problem i'm trying to figure out but i'm not too good with 
 arrays, just know the basics, if anyone could help me out on this it 
 would be wonderful :-)
 
 I have two sets of data in columns of a MySQL DB, these items are size 
 and price.
 
 Size is seperate by comma's in the first column, and I have it split 
 into a dropdown box no problem to read (For example):
 
 small
 medium
 large
 
 but then I have a price field, which contains 1.99,2.99,3.99 etc . 
 what I need to do is when someone selects an item from the dropdown - 
 say small as an example, it would know how to get 1.99 from the price 
 entry in the DB.  I guess what I need to do is somehow associate each 
 entry in the price field with those in the size, but I have no idea 
 how to do it :-(
 
 Any help would be really appreciated as this stumps the hell out of 
 me.
 
 Thanks
 
 Chris

I think you may have a problem with your database design? Can you explain 
a little more exactly what it is you are trying to do and perhaps someone 
can advise on how your data might best be structured.

-- 
David Robley
Temporary Kiwi!

Quod subigo farinam

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DB] Re: Array help needed :-(

2002-10-07 Thread David Robley

In article 000801c26e10$a2128510$f7fea8c0@chris, [EMAIL PROTECTED] 
says...
 Hi there everyone,
 
 I have a problem i'm trying to figure out but i'm not too good with arrays, just 
know the basics, if anyone could help me out on this it would be wonderful :-)
 
 I have two sets of data in columns of a MySQL DB, these items are size and price.
 
 Size is seperate by comma's in the first column, and I have it split into a dropdown 
box no problem to read (For example):
 
 small
 medium
 large
 
 but then I have a price field, which contains 1.99,2.99,3.99 etc . what I need 
to do is when someone selects an item from the dropdown - say small as an example, it 
would know how to get 1.99 from the price entry in the DB.  I guess what I need to do 
is somehow associate each entry in the price field with those in the size, but I have 
no idea how to do it :-(
 
 Any help would be really appreciated as this stumps the hell out of me.
 
 Thanks
 
 Chris

I think you may have a problem with your database design? Can you explain 
a little more exactly what it is you are trying to do and perhaps someone 
can advise on how your data might best be structured.

-- 
David Robley
Temporary Kiwi!

Quod subigo farinam

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php