回显SQL数据的DIV标记

时间:2015-04-15 19:55:15

标签: php html sql

<?php
mysql_connect("localhost", "username", "password") or die("Error connecting to database: ".mysql_error());
mysql_select_db("miceevent1") or die(mysql_error());
$query = $_GET['query']; 
// gets value sent over search form

$min_length = 3;

if(strlen($query) >= $min_length){ 
    $query = htmlspecialchars($query);   
    $query = mysql_real_escape_string($query);
    $raw_results = mysql_query("SELECT * FROM `TABLE 3`
        WHERE (`first_name` LIKE '%".$query."%')") or die(mysql_error());

    if(mysql_num_rows($raw_results) > 0){ 
        while($results = mysql_fetch_array($raw_results)){
            echo "<br><br><p><h7>".$results['full_name']. $results['flight_number']. $results['pickup_time'];
        }
    }
    else{ 
        echo "No results";
    }
}
else{ 
    echo "Minimum length is ".$min_length;
}
?>

我在同一页面上有css,我试图将查询结果放在div标签中。

1 个答案:

答案 0 :(得分:0)

在您的WHILE语句之后立即打开DIV标记。

将结束DIV标记放在While部分的结束大括号之后。