Entry
Can i use array for INSERT query?
May 2nd, 2002 01:24
Techek, Max Gall,
Depends! I'll assume you're talking about say .. PHP and MySQL. In that
case you could do this :
<?php
// your array
$ar = array("Techek","Logix","Marlow","Happy");
// produce a string with the contents of the array
$str = "'".implode("','",$ar)."'"; //
returns "'Techek','Logix','Marlow','Happy'"
// make a sql-query to be fired at your DB
$sql = "INSERT INTO table SET names ($str)";
// connect and fire here!
$result = mysql_query($sql);
?>
It might need to be modified, but this is the main idea. Build on it -
or ask a more specific way ... =8-)