Re: Problem with a dinamic variable --> array

From: Date: Wed, 23 Jul 2003 16:30:49 +0000
Subject: Re: Problem with a dinamic variable --> array
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-156482@lists.php.net to get a copy of this message
* Thus wrote Wan Do Ke (wanchan@fibertel.com.ar): > Here its the scenario: > > i have a table with campo1x, campo1y, campo2x, campo3y, ..... campo10x, > campo10y on the table ejes > > so what i need to do is to split an array that i send to this page on php .. > and include the values on this fields (but only on the fields that the $num > its writen) > (this is make by this way because the data is from flash) > > <?php > > > $propiedades= array("x","y"); > > // this values came from a $_POST (not now but they will) > > $ejey ="1,2,3,4"; > $ejex = "1,3,22,4"; > $num= "1,2,5,7"; > > > $valx = split(",", $ejex); > $valy = split(",", $ejey); It might make it easier if you set up your val as: $val['x'] = split(",", $ejex); $val['y'] = split(",", $ejey); > $numo= split(",", $num); > > for ($i = 0; $i < count($numo) ; $i++) { > for ($e = 0; $e < 2 ; $e++) { // then: and the current propiedades $thispropiedads = $propiedades[$e]; > > // here its campo1x so then on the update i know wich field i have to > update... > // the problem is that i dont know how can i retrive the value of $valx > and $valy > // this is OK .. because i know the name of the field that i > have to update... my problem is to catch the value ! > $a="campo" .$numo[$i] . $propiedades[$e]; // just to use the vars i set up $a = "campo" . $numo[$i] . "$thispropiedads"; > > /* this is WRONG ! i need $valy[0] or $valx[0] values checking > with $propiedades[$e] > > $b="\$val" . $propiedades[$e]. [$e]; // i think your mistake originally is that last $e should // be $i instead.. // Using the array I setup above would be: $b = $val[$thispropiedads][$i]; > > > */ > > // wrong the $b > $result2 = mysql_query("UPDATE ejes SET $a='$b'", $Connect); > > > } > } > > > ?> That should work. btw, next time Compose a new message when starting a new topic. Curt -- "I used to think I was indecisive, but now I'm not so sure."

« previous php.general (#156482) next »