私信  •  关注

Gajanan Kolpuke

Gajanan Kolpuke 最近创建的主题
Gajanan Kolpuke 最近回复了
5 年前
回复了 Gajanan Kolpuke 创建的主题 » 通过数组循环并将值传递给mysql query php

您正试图访问名为的键,而不是该键,您必须使用在SQL之前定义的变量。

$rows = json_decode($strJSON, true);

$select_data = [];
foreach( $rows  as $item ) {
    $cust_ord_no = $item['var1'];
    $cont_n = $item['var2'];
    $strSQL = "select * from test where col1 = '$cust_ord_no' and col2 = '$cont_n'";
    $select_data[] =mysqli_query($connsow, $strSQL);
}

您可以先用逗号分隔符分解输入,然后对分解后的每个数组再次应用&Prepare array for inserting records。所以,直接导入在SQL方法中创建了一个数组

foreach($array as $val) {
  $data = explode(', ', $val);

   foreach( $data as $row ) {
   $strInsertData = explode(' ', $row);
  $arrInsert[] = '("'.mysql_real_escape_string($strInsertData[0]).'", "'.$strInsertData[1].'", ' .$strInsertData[2].')';
  }
}   
mysql_query('INSERT INTO table (Director, Manager, Count) VALUES '.implode(',', $arrInsert));
5 年前
回复了 Gajanan Kolpuke 创建的主题 » jquery.css未应用于父容器[重复]

使用JSON格式而不是逗号格式。这样地,

$(".WarningCount").parent().css({"margin-left": "-1.4%"});