Php 如何使用变量进行MySQL查询?

Php 如何使用变量进行MySQL查询?,php,mysql,variables,mysqli,Php,Mysql,Variables,Mysqli,我有一个表单,它使用post方法将Roll_No值发送到php文件: //Query the database $resultSet = $mysqli->query("SELECT * FROM late WHERE 'Roll_No' LIKE '" . $_POST['Roll_No'] . "';"); //Count the returned rows if($resultSet->num_rows != 0){ //Turn the results into an

我有一个表单,它使用post方法将Roll_No值发送到php文件:

//Query the database
$resultSet = $mysqli->query("SELECT * FROM late WHERE 'Roll_No' LIKE '" . $_POST['Roll_No'] . "';");

//Count the returned rows
if($resultSet->num_rows != 0){  

//Turn the results into an array and echo them
    while($rows = $resultSet->fetch_assoc())
    {
        $Roll_No = $rows['Roll_No'];
        $Time = $rows['Time'];

        echo "<p>Roll_No: $Roll_No <br />Time: $Time</p>";
    }
//查询数据库
$resultSet=$mysqli->query(“选择*从“Roll\u No”LIKE”后面的位置开始”。$\u POST['Roll\u No']。”;”;
//计算返回的行数
如果($resultSet->num_rows!=0){
//将结果转换为数组并回显它们
而($rows=$resultSet->fetch_assoc())
{
$Roll_No=$rows['Roll_No'];
$Time=$rows['Time'];
回声“Roll\u No:$Roll\u No
时间:$Time

”; }
我的代码似乎无法从表单中获取Roll_No值,因此不会给出任何结果

编辑:这是表格

<form action="report-d1.php" method="post" />
<p>Search by Roll_No<input type="text" name="Roll_No" /></p>
<input type="submit" value="Submit" />
</form>

按卷号搜索


stop,将原始用户生成的变量放入您的查询将比我说的argggggggggggggggcheck要快得多,如果$\u POST是set…why LIKE and not=sidenote:标识符引号反勾将表单添加到问题中