Hi,
Below code is regarding to insert an array values into mysql db using php.
i dont know why the code is not inserting array values into database properly.
If is there any thing wrong with the code, Please let me know what is that!.
Here $final is an array containg the values of "ID,Name,Ph one" one by one.
array will be like $final=array(id 1,name1,ph1,id2 ,name2,ph2..... ........)
[PHP]
for($i=0;$i<cou nt($final);$i++ )
{
if($i%3==0)
{
$query="insert into cane (ID) values('$final[$i]')";
$v=$final[$i];
}
elseif($i%3==1)
$query="update cane set Name='$final[$i]' where ID='$v'";
else
$query="update cane set phone='$final[$i]' where ID='$v'";
$result=mysql_q uery($query)or die("Query failed : " . mysql_error());
}
[/PHP]
Sanjeev
Below code is regarding to insert an array values into mysql db using php.
i dont know why the code is not inserting array values into database properly.
If is there any thing wrong with the code, Please let me know what is that!.
Here $final is an array containg the values of "ID,Name,Ph one" one by one.
array will be like $final=array(id 1,name1,ph1,id2 ,name2,ph2..... ........)
[PHP]
for($i=0;$i<cou nt($final);$i++ )
{
if($i%3==0)
{
$query="insert into cane (ID) values('$final[$i]')";
$v=$final[$i];
}
elseif($i%3==1)
$query="update cane set Name='$final[$i]' where ID='$v'";
else
$query="update cane set phone='$final[$i]' where ID='$v'";
$result=mysql_q uery($query)or die("Query failed : " . mysql_error());
}
[/PHP]
Sanjeev
Comment