FORUMS


The Form Tools forums are no longer active, but the old posts have been archived here. Please see the Help page on how to get help / report issues.

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Best way to prepare variable(s) for UPDATE query? (mysql/php)
#2
Nevermind. I apply the loop to the array instead of the query; what a moron! Just goes to show, you can't legislate for stupidity.

++A

:q

PHP Code:
$data = array('col1' => 'one',
                     
'col2' => 'two',
                     
'col3' => 'three'
                     
);

foreach (
$data as $field => $value) {
  
$list[] = $field.'='."'".mysql_real_escape_string($value)."'";
}
$fields implode(', '$list);
    
$query "UPDATE table_name SET ".$fields." WHERE some_column=some_value"
Reply


Messages In This Thread
RE: Best way to prepare variable(s) for UPDATE query? (mysql/php) - by crunchers - May 5th, 2011, 11:01 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)