$rowdata = mysql_query("DESC ".$table_name."");
$names = array();
while($row = mysql_fetch_array($rowdata))
{
$names[] = $row['Field'];
$var_names[] = $row['Field'];
}
$qu1="\$qu=\"update ".$table_name." set ";
$qu1.="".implode('=\'".'."$"."jj.\"'".",", $names)."='Y'\";"."";
$qu3="'\".$".implode(".\"', '\".$", $var_names).".\"')\";";
echo $qu1;
输出:
更新inmines_contractor set contractor_id ='“。$ contractor_id。”',contractor_name ='“。$ contractor_name。”'
我想要echo / print更新查询值,如下所示 更新inmines_contractor set contractor_id ='“。$ contractor_id。”',contractor_name ='“。$ contractor_name。”'
答案 0 :(得分:0)
<?php
while($row = mysql_fetch_array($rowdata))
{
$names[] = $row['Field'];
$var_names[] = $$row['Field'];
}
$qu1="insert into ".$table_name."";
$qu1.=" (".implode(', ', $names)."";
$qu1.=" ) values ( "."'".implode('\', \'', $var_names)."' )"."";
?>
试试这个。这会有所帮助。
答案 1 :(得分:0)
$var_names[0] = "test";$var_names[1]= "test2";$qu1 = "";
$qu1.=" ) values ( '\".$".implode(".\"', '\".$", $var_names).".\"')";
echo $qu1;
)值('“。$ test。”','“。$ test2。”')