我动态检索用户的名字记录并在表格中打印,现在我想将所有这些记录打印到另一个表格中,包括表格的不同字段,例如,
table users:
1.
2.
3.
4.
5.
6.
我使用提交按钮
动态地将所有记录放入表格中<?php
$username=$_POST['u_name'];
echo $username;
$link = mysql_connect("localhost","root","") or die("Could not connect now");
mysql_select_db("wp_trainee_management") or die("Database not found");
//$image_caption = $_POST['image_caption'];
//$image_username = $_POST['attendance'];
//$u_name = $_POST['u_name'];
$today = date("Y-m-d");
$insert = "insert into attendance (attendance_date,name,presents)
values ('$today','".$username."','yes')";
$insertresults = mysql_query($insert) or die(mysql_error());
?>
我该怎么做?
答案 0 :(得分:0)
您可以使用foreach函数将每条记录插入另一个表格。
foreach($insertdata->result() as $user)
{
$this->db->insert('attendance',array($user->attendance_date,$user->name,$user->presents));
}