这里提供的代码不是用于制作而是开发,我有一个php页面如下:
mysql_select_db($database_dd, $dbs);
$query_Getuser = sprintf("SELECT * FROM users, firstname, lastname WHERE status = 'active'",
$Getuser = mysql_query($query_Getuser, $dd) or die(mysql_error());
$row_Getuser = mysql_fetch_assoc($Getuser);
$totalRows_Getuser = mysql_num_rows($Getuser);
if($Getuser){
// insert my my output values into my new table
}
<table class="table table-responsive">
<tr>
<td>User</td>
<td><?php echo $row_Getuser['username']; ?></td>
</tr>
<tr>
<td>Status</td>
<td><?php echo $row_Getuser['status']; ?></td>
</tr>
<tr>
<td>Total Active Users</td>
<td><?php echo $totalRows_Getuser ?></td>
</tr>
<tr>
<td>Total Inactive Users </td>
<td><?php echo $totalRows_WScore ?></td>
</tr>
</table>
问题:我厌倦了捕获输出并将其重新插入到我在数据库中创建的新表中。
我尝试了隐藏字段,但这需要一个页面按钮isset()
然后我教会了如何使用Session_start()
数据:
$_SESSION['username'] = $_POST['username'];
$_SESSION['status'] = $_POST['status'];
$_SESSION['totalRows_Getuser'] = $_POST['totalRows_Getuser'];
我似乎无法插入数据。可以做些什么?
答案 0 :(得分:0)
你可以在
时完成while($row = mysql_fetch_assoc($Getuser)){
.... <?= $row_Getuser['username'] ?>
<?= $row_Getuser['status'] ?>
}
我更希望让MySQL计数。
SELECT COUNT(users) AS ActiveUsers,* FROM users, firstname, lastname WHERE status = 'active'
答案 1 :(得分:0)
if both table have same table schema you can use below query
INSERT INTO newtable
SELECT * FROM users
OR if you want to just copy selected columns data into another table you can use.
INSERT INTO Customers (CustomerName, Country)
SELECT SupplierName, Country FROM Suppliers