0
我在php和mysqli中構建了一個自定義社交網絡。我有一個名爲notifications.php的頁面,顯示用戶網站通知以及朋友請求!把所有我想要做的就是讓用戶通過點擊一個按鈕來清除他的通知列表!空的通知列表
在我的HTML我有這個...
<p><span id="purgeList"><?php echo $purgeList; ?></span></p>
<h2>Notifications</h2><?php echo $notification_list; ?></div>
,到目前爲止,我所有的按鈕就是這個....
<?php
$purgeList = '<button disabled>Purge your List</button>';
if ($notification_list == true){
$purgeList = '';
}
?>
自己獲取使用該拉的通知腳本!
$notification_list = "";
$sql = "SELECT * FROM notifications WHERE username LIKE BINARY '$log_username' ORDER BY date_time DESC LIMIT 5";
$query = mysqli_query($db_conx, $sql);
$numrows = mysqli_num_rows($query);
if($numrows < 1){
$notification_list = "You do not have any notifications";
} else {
while ($row = mysqli_fetch_array($query, MYSQLI_ASSOC)) {
$noteid = $row["id"];
$initiator = $row["initiator"];
$app = $row["app"];
$note = $row["note"];
$date_time = $row["date_time"];
$date_time = strftime("%b %d, %Y", strtotime($date_time));
$notification_list .= "<p><a href='user.php?u=$initiator'>$initiator</a> | $app<br />$note</p>";
}
}
mysqli_query($db_conx, "UPDATE users SET notescheck=now() WHERE username='$log_username' LIMIT 1");
做一個Ajax調用,一旦按鈕被點擊清除通知表用戶,然後從HTML刪除它們,或使「看到」 – Cjueden 2013-03-05 20:44:40