Php 如何进行查询和显示数据
我尝试输入数字表单,并在grapht.php页面中进行搜索。例如,我编写代码:Php 如何进行查询和显示数据,php,forms,input,numbers,integer,Php,Forms,Input,Numbers,Integer,我尝试输入数字表单,并在grapht.php页面中进行搜索。例如,我编写代码: <form action="grapht.php" method="post"> Name: <input type="text" name="number" autocomplete="off"><br> <input type="submit"> </td> </form> <? $number=
<form action="grapht.php" method="post">
Name: <input type="text" name="number" autocomplete="off"><br>
<input type="submit">
</td>
</form>
<? $number= $_POST["number"]; ?>
名称:
然后查询我的MySQL表:
$shipmin = 1;
$shipmax=$number;
$uzklausimas ="SELECT * FROM MyGuests WHERE id >= '$shipmin' AND id<= '$shipmax'";
$minmax=mysqli_query($conn,$uzklausimas);
while($ru=mysqli_fetch_assoc($minmax)){
echo "$ru[id] <br>";
}
$shipmin=1;
$shipmax=$number;
$uzklausimas=“从MyGuests中选择*,其中id>='$shipmin'和id是否在此行之前初始化数据库连接($conn)
$minmax=mysqli_query($conn,$uzklausimas);
如果我写行$shipmax=45;
它运行良好,但我有从1到45的静态日期。如果我写$shipmax=$number;
它不工作。我所有的代码
<?php
$servername = "localhost";
$username = "xxxxx";
$password = "xxxx";
$dbname = "xxxxx";
$conn = mysqli_connect($servername, $username, $password, $dbname);
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
$shipmin = 1;
$shipmax=$number;
$uzklausimas ="SELECT * FROM MyGuests WHERE id >= '$shipmin' AND id<='$number'";
$minmax=mysqli_query($conn,$uzklausimas);
while($ru=mysqli_fetch_assoc($minmax)){
echo "$ru[id] <br>";
}
mysqli_close($conn);
?>
<form action="forum.php" method="post">
Name: <input type="text" name="name" autocomplete="off"><br>
<input type="submit">
</td></form>
<? $number= (int)$_POST["name"]; ?>
<?php echo $number; ?>
<br>
“但我的代码不起作用“-以什么方式?错误消息?检查服务器错误日志?错误的结果?计算机着火了?如果我写$shipmax=45行,你应该使用;它工作得很好,但是如果我写$shipmax=$number;使用var\u dump检查$\u POST变量的内容不是工作。如果是空的,你的问题就在你的表格里。你能把所有的剧本都贴出来吗?我把所有的剧本都放在最上面