if(isset($_POST['id']))
{
// id to search
$id = $_POST['id'];
// Fetch Data From DataBase
$sql ="SELECT * , DATE_FORMAT(birthdate, '%d/%m/%Y') AS birthdate FROM `personal_info` WHERE `personal_id_number` = $id ORDER BY birthdate DESC";
$result = $conn -> query($sql);
if ($result -> num_rows <> 0) {
while ( $row = $result -> fetch_assoc() ) {
echo "<tr><td>" . $row["person_name"]
. "</td><td>". $row["personal_id_number"]
. "</td><td>". $row["birthday"]
. "</td><td>" . $row["adress"]
. "</td><td>" . $row["phone_number"]
. "</td><td>" . $row["email"]
. "</td><td colspan='3' class='more fit'>"
. $row["more_info"]
. "</td></tr>";
}
}
只有当搜索条件是数据库中有数字的某个字段时,这个搜索字段才起作用,比如“个人id”和“电话号码”。
否则,如果我把“personal\u name”作为搜索条件,我会得到一个错误“notice:trying to get property'num\u rows'of non object”。
暂无答案!
目前还没有任何答案,快来回答吧!