在PHP中从MySQL数据库中获取数据,解析错误:语法错误,意外'<'

时间:2017-01-08 06:58:34

标签: php html mysql

我正在开发一个搜索字段,通过过滤下拉列表中的某些值来检索数据库中的数据。我一直收到以下错误:

  

解析错误:语法错误,意外'<'

我用来检索数据的函数如下:

<?php
function show() {
    $connect=mysqli_connect("localhost","root","","tsms");

    $output ='';

    $route = $_POST['from'];

    $query = "SELECT * FROM bus WHERE route='$route'";
    $result = mysqli_query($connect,$query);
    $count = mysqli_num_rows($query);

    for($i=0;$i<$count;$i++) {
        while($row = mysqli_fetch_assoc($result)){
            $imageData = '<img height="80" width="70" src="data:image/jpeg;base64,'.base64_encode( $row['image'] ).'"/>';
            $arrival = $row['arrival_time'];
            $departure = $row['departure_time'];
            $type = $row['bus_type'];
            $class = $row['class'];
            $name = $row['bus_name'];
            $facilities = $row['facilities'];
            $reservation = $row['reservation_fee'];

            $output = '<div style="background-color:lightgrey;width:1300px;border:2px solid blue;padding:5px;margin:5px;height:150px;">'.$imageData.' '.$arrival.' '.$departure.' '.$type.' '.$class.' '.$name.' '.$facilities.' '.$reservation.
            <button class="button">View Seats &raquo;</button>'</div>'; 
        }
        echo $output;
    } 
    mysqli_close($connect);
}
?>

1 个答案:

答案 0 :(得分:2)

您错过了Sub foo() ToggleOutlineGroup Sheet1, 10 End Sub Sub ToggleOutlineGroup(sht As Worksheet, row As Long) sht.Rows(row).ShowDetail = Not (sht.Rows(row).ShowDetail) End Sub 附近的单引号'

更改此行

<button.........

$output = '<div style="background-color:lightgrey;width:1300px;border:2px solid blue;padding:5px;margin:5px;height:150px;">'.$imageData.' '.$arrival.' '.$departure.' '.$type.' '.$class.' '.$name.' '.$facilities.' '.$reservation.
             <button class="button">View Seats &raquo;</button>'</div>';