View Single Post
Old 03-10-2006, 04:42 PM   #3 (permalink)
office politics
office politics's Avatar
 
It's all just 1s and 0s

Join Date: Jan 2004

Location: in the lab

Posts: 4,410

office politics will become famous soon enough

Default

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), 04) == "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."
";


office politics is offline