我想将所有循环值插入到我的代码中,只写入最后一个值 我的循环。如何检索所有循环值并插入数据库, 帮助我克服这一点。而且我必须在单个单元格中插入所有值 我怎么能这样做。
<?php
$server="localhost";
$user="root";
$pswd="";
$dbname="desig";
$conn=mysql_connect($server,$user,$pswd);
mysql_select_db($dbname,$conn);
/*------Monthly-------*/
for($f=1;$f<=15;$f++)
{
$factorname="wa".$f;
if(!empty($_POST[$factorname]))
{
for($l=0;$l<$f;$l++)
$factor=$_POST[$factorname];
$labelname="fa".$l;
$labmonth= $_POST[$labelname];
$monthres=array();
$impmonthres=array();
$monthres[$l]=$labmonth.'-'.$factor;
$t=0;
$impmonthres[$t]=$monthres[$l].':';
$t++;
}
}
//$factorimp=array();
// $factorimp=implode(',',$monthres);
/*------Quaterlyweightage-------*/
for($w=1;$w<=15;$w++)
{
$quaweight="we".$w;
if(!empty($_POST[$quaweight]))
{
for($q=0;$q<$w;$q++)
$quaweightvalue=$_POST[$quaweight];
$qualabel="qa".$q;
$qualabelname=$_POST[$qualabel];
$quares=array();
$quares[$q]=$qualabelname.'-'.$quaweightvalue;
$quaresfin=array();
$k=0;
$quaresfin[$k]=$quares[$q].':';
$k++;
}
}
/*-------Annually-------*/
$annualyvalue=$_POST['annualy'];
if(!empty($_POST['annualy']))
{
$annualyres='A1'.'-'.$annualyvalue;
}
echo $annualyres;
foreach($impmonthres as $monthvalue)
{
echo $monthvalue;
}
foreach($quaresfin as $Quaterlyvalue)
{
echo $Quaterlyvalue;
}
$month=mysql_query("insert into workupdate(Empname,Designation,Monthly,Quaterly,Annualy)values('user','juniordeveloper','$monthvalue','$Quaterlyvalue','$annualyres') ",$conn);
?>
答案 0 :(得分:0)