就在我有表格之前,代码将从中接收Nr1和Nr2,我也已经创建了一个表(Nr,x,y,z)。现在我需要在表中找到值x,其中Nr等于Nr1。 我收到正确的echo $ Nr1,但没有收到$ x1,这意味着错误在mysql_query中。请帮我找到它。谢谢。
<?php
if(isset($_POST['addy']))
{
$con=mysqli_connect("***","***","***","****");
if (mysqli_connect_errno()) {
echo "No MySQL: " . mysqli_connect_error();
}
$Nr1 = $_POST['Nr1'];
$Nr2 = $_POST['Nr2'];
echo $Nr1;
$x1 = mysql_query("SELECT `x` FROM `table` WHERE `Nr`='$Nr1'");
echo $x1;
mysqli_close($con);
}
?>
答案 0 :(得分:1)
$x1 = mysql_query("SELECT `x` FROM `table` WHERE `Nr`='$Nr1'");
输出不是字符串!要获得结果,请进行一个while循环:
while($row=mysqli_fetch_assoc($x1)){
echo $row['RowNr1'];
echo ' - ';
echo $row['RowNr2'];
echo '<br>';
}
答案 1 :(得分:0)