Re: building a mysql query
| From: | Carlos Henrique | Date: | Mon, 19 Jun 2000 13:43:12 +0000 |
| Subject: | Re: building a mysql query | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-477@lists.php.net to get a copy of this message | ||
Put your $ sign in the $alpha var not in quotes, like this:
$sqlinsert = $sqlinsert . "," . $$alpha[$i];
Carlos
> 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