Suggest a feature
×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: PHP
Posted by: Dylan Lopez
Added: Mar 5, 2018 8:53 AM
Views: 7
  1. function build_sql_query($usrData) {
  2.    $count = 0;
  3.    $fields = '';
  4.  
  5.    foreach($usrData as $col => $val) {
  6.       if ($count++ != 0) $fields .= ', ';
  7.       #$col = mysql_real_escape_string($col);
  8.      #$val = mysql_real_escape_string($val);
  9.      $fields .= "`$col` = '$val'";
  10.    }
  11.  
  12.    return $fields;
  13. }
  14. $sql = array ("ASIN" => $product['ASIN'],
  15.                 "parentASIN" => $product['parentASIN']);
  16. //build SQL query
  17. $sql = "INSERT IGNORE  `$childASIN_table` SET " .build_sql_query($sql);
  18. echo $sql;