Tuesday, May 29, 2012

Cannot query inside the while loop in PHP ? Here is the solution

Here is the solution


$sql = "select id from student where classId = 5";
$view = mysql_query($sql);

while($row = mysql_fetch_array($view))
{
      $array[] = $row;
}


foreach($array as $arow)
{

$sqli = "insert into course (studentId,course) values (".$ arow ["id"].",'".Maths.'")";
mysql_query ($sqli);

}

No comments:

Post a Comment