表没有填写xammp使用PHP代码

时间:2018-01-29 16:17:26

标签: php mysql xampp

对于以下代码,我没有得到预期的输出。我希望获取表中的数据并将其放在新表中。表格l3包含rollnodepartmentcgpa。表格l4必须填充rollnodepartment,{{ 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);
?>

0 个答案:

没有答案