building a mysql query

From: Date: Mon, 19 Jun 2000 08:25:49 +0000
Subject: building a mysql query
Groups: php.db 
Request: Send a blank email to php-db+get-473@lists.php.net to get a copy of this message
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) //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

« previous php.db (#473) next »