为什么这个查询要显示任何信息?

时间:2015-07-04 15:11:43

标签: php mysql pdo

我在此查询中遇到问题从不显示信息。

以下是代码:

$db = new DB();
$db->connect();
$query2 = $db->query('SELECT pagado FROM pedidos WHERE email='.$_POST["email"].'');
$row2 = $db->fetch_array($query2);
$query3 = 'SELECT instalado FROM pedidos WHERE email='.$_POST["email"].'';
$row3 = $db->fetch_array($query);
if ($row2["email"] == "S"){
    echo "Su pedido se está instalando";
    echo $resultado3;
}elseif ($row3["email"] == "S"){

2 个答案:

答案 0 :(得分:0)

您从查询中提取pagado并尝试与错误的电子邮件匹配

if ($row2["email"] == "S"){

它将是

if ($row2["pagado"] == "S"){

同时将您的查询更改为

 <?php
 $db = new DB();
  $db->connect();
  $query2 = $db->query("SELECT pagado FROM pedidos WHERE email='".$_POST['email']."'");
  $row2 = $db->fetch_array($query2);
  $query3 = "SELECT instalado FROM pedidos WHERE email='".$_POST["pagado"]."'";
  $row3 = $db->fetch_array($query3);
if ($row2["pagado"] == "S"){
    echo "Su pedido se está instalando";
echo $resultado3;
}elseif ($row3["instalado"] == "S"){

答案 1 :(得分:0)

没有变量,例如$query所以

改变你的

$row3 = $db->fetch_array($query);

$ row3 = $ db-&gt; fetch_array($ query3);

您也可以更改两个查询并将其合并为一个

$query2 = $db->query('SELECT pagado,instalado FROM pedidos WHERE email='.$_POST["email"].'');

$row2 = $db->fetch_array($query2);