这里提供的代码不是用于生产而是用于开发,我有一个 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'];
我似乎无法插入数据。可以做什么?
最佳答案
你可以用 while 来做到这一点
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'
关于php - 将 php 输出重新插入数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29764236/