Re: array output as a variable?

From: Date: Thu, 12 Apr 2001 17:00:40 +0000
Subject: Re: array output as a variable?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-48252@lists.php.net to get a copy of this message
$info_request = array (1 => "firstname","lastname","email","howfound","optin","comments","request_type", "request_bucket","date"); $flds = implode(",", $info_request); $sql = "INSERT INTO mytable($flds)" mysql_query($sql) hope it helps at least a little. -elias http://www.kameelah.org/eassoft "midget2000x" <midget@elaris.com> wrote in message news:01041201234102.19013@mullhawk.thewhiteroom.com... > another newbie programmer question... > is it possible to output the results of an array loop into a variable, or > directly into an SQL call? > > Obviously the code below is impossible, but illustrates what I want to do: > > //declare the array > $info_request = array (1 => "firstname","lastname","email","howfound","optin","comments","request_type", "request_bucket","date"); > > //output the array loop results to a variable > $array_results = foreach ($info_request As $value) { print "$value,"; } > > //place the output variable into an SQL call (therefore making it > dynamic): > > INSERT INTO $tablename ($array_results) > ... > > thanks! > ----------- > providing the finest in midget technology > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.general (#48252) next »