对于以下代码,我没有得到预期的输出。我希望获取表中的数据并将其放在新表中。表格l3
包含rollno
,department
,cgpa
。表格l4
必须填充rollno
,department
,{{ 1}}检查是否指定了所需的cgpa
。
cgpa
new.php具有以下代码
<?php
include "new.php";
$cgpa = 4;
$sql = "SELECT ROLLNO, NAME, DEPARTMENT, CGPA FROM l3 WHERE CGPA >= '$cgpa'";
$result = mysqli_query($link, $sql);
if (mysqli_num_rows($result) > 0) {
while($row = mysqli_fetch_assoc($result)) {
$sql2 = "INSERT INTO l4 (ROLLNO,NAME,DEPARTMENT,CGPA)VALUES({$row['ROLLNO']},{$row['NAME']},{$row['DEPARTMENT']},{$row['CGPA']})";
mysqli_query($link, $sql2);
}
}
else
echo "No records found.";
mysqli_close($link);
?>