Page 1 of 1

problem in INSERTing a array data in a column

Posted: Tue Apr 07, 2009 3:45 am
by anaspk
array $sub2 cant insert the values in a colum 'ord' of table order in the same database
<?php
include('datacon.php');
$sq1 = "SELECT regno FROM patientreg";
$result=mysql_query($sq1);
$num=mysql_num_rows($result);

for ($i=1; $i<=$num; $i++)
{
$row=mysql_fetch_array($result);
$val=$row['regno'];
$regno = $val;
$sub= substr($val,2);
$len=strlen($sub)-3;
$sub2= substr($sub,0,$len);
$sql2="INSERT INTO order(ord) VALUES('$sub2')";
echo $sub2."<br>";

//$sql2="UPDATE patientreg SET order = '$sub2' WHERE regno = '$regno'";
$query=mysql_query($sql2);
}
?>

Re: problem in INSERTing a array data in a column

Posted: Tue Apr 07, 2009 3:54 am
by papa
Won't work:
$row=mysql_fetch_array($result);
$val=$row['regno'];

Use:
http://us.php.net/manual/en/function.my ... -assoc.php