only if you want multiple statements to run
i have this code that works. it is a part of an unrelated script
PHP Code:
function insert($x, $stack, $table) {
$query = "insert into ".$table." set ";//move data into table
for ($i=0;$i<$x;$i+=2) {
if (substr(pos($stack), 0, 4) == "com_") // is field name prefixed with com_?
$query = $query.substr_replace(pos($stack),"",0,4)."='";//Shave com_ & Add field name to the query
else
$query = $query.pos($stack)."='";//Get field name & add it to the query
next($stack);//Move to data entry
if(is_array(pos($stack))) { //Is data entry from checkboxes?
foreach(pos($stack) as $element) // Each checkbox entry
$query = $query.$element.","; //gets added to the query
$query= $query."',";//finish query
}
else
$query= $query.pos($stack)."',";//Get data entry & add it to the query
next($stack);//Get next field name
//echo $i."
";
}