如何使用php通过选择列表从表中获取周数据计数、昨天数据、月份数据

bvpmtnay  于 2021-06-18  发布在  Mysql
关注(0)|答案(1)|浏览(273)

我有三个数据库表--
表“图像”

{ id 
    user_name 
    name  blog 
    date

}
用户- { id user_name name Blob (for image ) date } 优胜者\用户 { id user_name price date } 我想按昨天、周、月统计数据。在昨天、一周或一个月的数据表中插入了多少数据。。。显示数据的示例图像
html列表---

<select name="data"> 
<option>Yesterday</option> 
<option>Week </option> 
<option>Month </option> 
</select>

当我点击“昨天”时,它会显示昨天插入了多少数据(count),
当我点击一周时,它会显示一周内插入了多少数据(count),
以及
当我点击month时,它会显示这个月插入了多少数据(count),
从图像数据

<?php

 include ("config.php");  
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$sql="select count('1') from images";
$result=mysqli_query($mysqli,$sql);
$row=mysqli_fetch_array($result);
echo "<h3>$row[0]</h3>";
mysqli_close($mysqli);
?>

从用户表数据--

<?php

 include ("config.php");  
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$sql="select count('1') from users ";
$result=mysqli_query($mysqli,$sql);
$row=mysqli_fetch_array($result);
echo "<h3>$row[0]</h3>";
mysqli_close($mysqli);
?>

从用户计数数据

<?php

 include ("config.php");  
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$sql="select count('1') from winner_user";
$result=mysqli_query($mysqli,$sql);
$row=mysqli_fetch_array($result);
echo "<h3>$row[0]</h3>";
mysqli_close($mysqli);
?>

请帮我找到最好的解决方案,

gr8qqesn

gr8qqesn1#

您是否正在寻找激活选择框的方法?你可以用 <select name="data" onchange="switchTo(this.value)"> 然后可以使用ajax在switchto函数中获取值。

相关问题