note 1417 deleted from list by ronabop

From: Date: Thu, 31 Aug 2000 05:34:45 +0000
Subject: note 1417 deleted from list by ronabop
Groups: php.notes 
Request: Send a blank email to php-notes+get-3731@lists.php.net to get a copy of this message
I've been trying to put the field names of the rows I want to select from the table in a $fields variable, like this:<br><br> <pre> $fields = 'id, name, salary'; $result = mysql($conn, "SELECT $fields FROM employees"); $fields = '$'.str_replace(", ",', $',"$fields"); while (list($fields) = mysql_fetch_row($result)) { print("$fields"); } </pre> <br><br> I also tried to eval() the $values, but that does not seem to work either. I spent few hours trying to find out how to do this, but...there is no solution. list() re-creates the $values variable as a one variable, not three variables as shown in earlier code.

« previous php.notes (#3731) next »