我正在尝试根据表单上的用户输入从我的数据库中返回一个值。当我使用一个值运行代码时,它可以工作,但是当我输入变量时,它不会。我确定这很简单,但我就是不明白?
这是有效的代码:
$sql_beam = mysqli_query($link,"SELECT cost_ft FROM Beams WHERE number = '201'");
while($row = mysqli_fetch_array($sql_beam))
{
echo "<p>" . $row['cost_ft'] . "</p>";
echo "<br>";
}
当我将其更改为此时,它不会:
$beam_num = $_POST['Beam Number'];
$sql_beam = mysqli_query($link,"SELECT cost_ft FROM Beams WHERE number = '$beam_num'");
while($row = mysqli_fetch_array($sql_beam))
{
echo "<p>" . $row['cost_ft'] . "</p>";
echo "<br>";
}