Re: building a mysql query

From: Date: Mon, 19 Jun 2000 13:43:31 +0000
Subject: Re: building a mysql query
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-476@lists.php.net to get a copy of this message
Try adding the eval() function around your $alpha[$i] - I had a similar problem passing variable names between forms Lez > Hi, > > I'm dynamically creating a insert query in php with a for loop to get the > variable names of the input boxes. After the query is done building it's > self i output it and i find that it is outputting the string as it is. IE > not the values of the variables but the actual variable names themselves. > Here is my code and the output to see if it helps, > > $alpha = array('a','b','c','d'); > $sqlinsert = "Insert into $dep values (0,'$Emp'"; > > for ($i = 0; $i < (mysql_num_fields ($result) - 2); $i++) > { > $sqlinsert = $sqlinsert . "," . '$' .$alpha[$i] ; > } > $sqlinsert = $sqlinsert . ")" ; > echo $sqlinsert; > > // THis is the output of the For loop Query > > Insert into Copier values (0,'2',$a,$b) > > > file://This is the output of the static query > $part = "Insert into $dep values (0,'$Emp',$a,$b)"; > echo $part; > > Insert into Copier values (0,'2',3,4) > > > Does anyone know of a way to make this thing work?? > > Thanks, > Ryan > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net > For additional commands, e-mail: php-db-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.db (#476) next »