http://www.runoob.com/php/php...
Why only one piece of data is displayed after using this example operation, and how to display all data that meets the conditions
< /p>
For example, the query field I use is yesterday_str to query the data of 2017-04-18
How can we extract all the data including this from 2017-04-18?
< /p>
php code
<?php
$q = isset($_GET["q"]) ? intval($_GET["q"]) : '';
if(empty($q)) {
echo 'Please select a date';
exit;
}
$con = mysql_connect('127.0.0.1', 'root', '');
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("rizhifenxi", $con);
mysqli_set_charset($con, "utf8");
#$sql="SELECT * FROM keywords WHERE id = '".$q."'";
$sql="SELECT * FROM keywords WHERE yesterday_str = '".$q."'";
$result = mysql_query($sql);
echo "<table border='10'>
<tr>
<th>Date</th>
<th>Keywords</th>
<th>Number of visits</th>
</tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['yesterday_str'] . "</td>";
echo "<td>" . $row['keywords'] . "</td>";
echo "<td>" . $row['count'] . "</td>";
echo "</tr>";
}
echo "</table>";
mysql_close($con);
?>
html code:
<html>
<head>
<meta charset="utf-8">
<script src="/static/selectuser.js"></script>
</head>
<body>
<form>
Select a User:
<select name="yesterday_str" onchange="showUser(this.value)">
<option value="">Select a date:</option>
<option value="1">2017-04-20</option>
<option value="2">2017-04-21</option>
<option value="3">2017-04-22</option>
<option value="4">2017-04-23</option>
</select>
</form>
<p>
<p id="txtHint"><b>yesterday_str info will be listed here.</b></p>
</p>
</body>
</html>
PHP中文网2017-05-16 13:11:21
$sql="SELECT * FROM Websites WHERE id = '".$q."'";
This only displays the data of the corresponding id value. Remove all the ones after Websttes to display all, or the limit N is N.
Just rewrite it according to your requirements
$sql="SELECT * FROM Websites WHERE yesterday_str = '".$q."'";
Pay attention to the date format you upload.
巴扎黑2017-05-16 13:11:21
global $empire;
$query = "select * from table where date='2017-04-18'" ;
$sql=$empire->query($query);
while($row=$empire->fetch($sql){
//code
$data[]=$row;
}
print_r($data);
The processing side is written like this. Is it convenient to provide any system or framework used in the backend?
某草草2017-05-16 13:11:21
1. Determine whether the passed value is correct;
2. Print and execute the SQL statement to check whether it is correct