如何将选定的数据库放入第二页,然后插入另一个表中。
这是我的第一页:
<?php
session_start();
$result = mysqli_query($con,"SELECT * FROM qwerty
WHERE ID LIKE '$id' ");
while($row = mysqli_fetch_array($result))
{
echo "Name:" . $row['Fname'] . " " . $row['Lname'];
}
$_SESSION['fname']=$row['Fname'];
$_SESSION['lname']=$row['Lname'];
?>
这是我的第二页:
<?php
session_start();
$sql="INSERT INTO login (Fname, Lname)
VALUES
('{$_SESSION['fname']}','{$_SESSION['lname']}')";
答案 0 :(得分:0)
$sql="INSERT INTO login set
Fname='".$_SESSION['fname']."',
Lname='".$_SESSION['lname']."'";
答案 1 :(得分:0)
请查看并尝试以下操作:
session_start();
$firstName = $_SESSION['fname'];
$lastName = $_SESSION['lname'];
$sql="INSERT INTO `login` (Fname, Lname) VALUES ('$firstName','$lastName')";
同时确保填充会话时
while($row = mysqli_fetch_array($result))
{
echo "Name:" . $row['Fname'] . " " . $row['Lname'];
}
$_SESSION['fname']=$row['Fname']; //CHECK
$_SESSION['lname']=$row['Lname'];
分配了数据。也许在循环中添加它。如果您正在寻找最后一条记录,那么无论如何都会被记录:
while($row = mysqli_fetch_array($result))
{
echo "Name:" . $row['Fname'] . " " . $row['Lname'];
$_SESSION['fname']=$row['Fname']; //CHECK
$_SESSION['lname']=$row['Lname'];
}