Re: Trying to read the value of a var...

From: Date: Sat, 10 May 2003 14:50:48 +0000
Subject: Re: Trying to read the value of a var...
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-147117@lists.php.net to get a copy of this message
On Sat, 10 May 2003, Jason Wong wrote: > On Saturday 10 May 2003 03:55, Amanda McComb wrote: > > [snip] > > > However, when all fields are correct and I go to insert it into the > > database, I don't get the correct value: > > > > while ($search_result = mysql_fetch_array($search_results)) { > > $name2 = "quantity_"; > > $name2 .= $search_result['conference_component_cd']; > > ?><BR><? > > echo $$name2; //HERE, the correct value displays > > What exactly does it display? 2 for the first one 4 for the second These were the values I entered into the fields. > > > if ($$name2){ > > > > $query2 = "INSERT INTO customer_conference_t "; > > $query2 .= "(customer_conference_cd, customer_id, > > conference_component_cd, quantity) "; > > $query2 .= " values('','$customer_id', > > $search_result[conference_component_cd], $$name2)"; > > > > echo $query2;?><BR><? //Here, it displays like this > > //$quantity_10 > > And what exactly does this display? $quantity_10 and $quantity_13 The numbers behind it are the primary keys of the fields. > > There are very few cases where the use of variable variables is justified. I > suggest you change to using arrays instead -- they're easier to understand > and more logical to process. I tried to figure out a way to use an array in this case, but I was stumped. I would need something more like a hash, that would hold both the primary key and a quantity. Does php have something like that? Is there a place I can go to find an example? > > -- > Jason Wong -> Gremlins Associates -> www.gremlins.biz > Open Source Software Systems Integrators > * Web Design & Hosting * Internet & Intranet Applications Development * > ------------------------------------------ > Search the list archives before you post > http://marc.theaimsgroup.com/?l=php-general > ------------------------------------------ > /* > Rubber bands have snappy endings! > */ > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > >

« previous php.general (#147117) next »