MySQL有显示记录的问题

时间:2018-12-22 23:13:30

标签: php mysql pdo

我一直在为一个项目的代码编写代码,该代码将显示载具BOLO的外观(当心)。 Bolo的记录存储在称为bolos的表中。当我退回案件时,它会回显“ No Bolos On Vehicle”,但是如果找到了一个bolo,它将不会显示它,也不会显示“ No Bolos On Vehicle”。

$q = strip_tags($_GET['q']);
$getVeh = "SELECT * FROM vehicles WHERE vehicle_id='$q'";
$result = $pdo->prepare($getVeh);
$result->execute();
while ($row = $result->fetch(PDO::FETCH_ASSOC))
    {
    echo "<h6>Plate: " . $row['vehicle_plate'] . "</h6><br-leo-name-search>";
    echo "<h6>Color: " . $row['vehicle_color'] . "</h6><br-leo-name-search>";
    echo "<h6>Model: " . $row['vehicle_model'] . "</h6><br-leo-name-search>";
    echo "<h6>Insurance Status: " . $row['vehicle_is'] . "</h6><br-leo-name-search>";
    echo "<h6>Registration Status: " . $row['vehicle_rs'] . "</h6><br-leo-name-search>";
    echo "<h6>VIN: " . $row['vehicle_vin'] . "</h6><br-leo-name-search>";
    echo "<h6>Owner: " . $row['vehicle_ownername'] . "</h6><br-leo-name-search>";
    $plate = $row['vehicle_plate'];
    $stmt = $pdo->prepare("SELECT * FROM bolos WHERE vehicle_plate =:veh_plate");
    $stmt->bindParam(':veh_plate', $row['vehicle_plate']);
    $stmt->execute();
    $bolosRows = $stmt->fetch(PDO::FETCH_ASSOC);
    if (empty($bolosRows['bolo_id']))
        {
        echo "<hr><h6>No Bolos On Vehicle</h6>";
        }
      else
        {
        $getVehBolo = "SELECT * FROM bolos WHERE vehicle_plate=:plate";
        $result = $pdo->prepare($getVehBolo);
        $stmt->bindValue(':plate', $plate);
        $result->execute();
        while ($row = $result->fetch(PDO::FETCH_ASSOC))
            {
            echo "<table>";
            echo "<tr>";
            echo "<td><center><font color='red'>" . $row['bolo_reason'] . "</font></center></td>";
            echo "<td><center><font color='red'>" . $row['bolo_created_on'] . "</font></center></td>";
            echo "</tr>";
            }

        echo "</table>";
        }
    }

0 个答案:

没有答案