gpt4 book ai didi

PHP MYSQL,简单通知

转载 作者:行者123 更新时间:2023-11-29 11:21:20 25 4
gpt4 key购买 nike

有人可以帮助我如何在我阅读或打开通知后删除通知上的计数或数字...我希望你能理解,抱歉,如果它含糊不清并且我的英语不好。这是我的示例代码..

/index.php

   <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">

function addmsg(type, msg){

$('#notification_count').html(msg);

}

function waitForMsg(){

$.ajax({
type: "GET",
url: "select.php",

async: true,
cache: false,
timeout:50000,

success: function(data){
addmsg("new", data);
setTimeout(
waitForMsg,
1000
);
},
error: function(XMLHttpRequest, textStatus, errorThrown){
addmsg("error", textStatus + " (" + errorThrown + ")");
setTimeout(
waitForMsg,
15000);
}
});
};

$(document).ready(function(){
waitForMsg();
});
</script>



</head>

<body>

<span id='notification_count'></span>
<a href="notificationview.php" id="notificationLink" onclick = "return getNotification()">Notifications</a>
<div id="HTMLnoti" style="textalign:center"></div>


<br>
<p style="font-weight: bold; font-size: 20px; font-family: Tahoma;">Admin panel</p>
<form action="index.php" method="post">
<input type="text" required name="notification" autofocus="on" autocomplete="off">
<br>
<br>
<input type="text" name="status" value="unread" style="display: none;">
<input type="submit" name="btnsub" value="Submit">
</form>

然后是我的/select.php,为什么我的通知很重要..

 <?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "messageTest";

// Create connection

$conn = new mysqli($servername, $username, $password, $dbname);

// Check connection

if ($conn->connect_error) {

die("Connection failed: " . $conn->connect_error);

}

$sql = "SELECT * from messageTest where status = 'unread'";
$result = $conn->query($sql);
$row = $result->fetch_assoc();
$count = $result->num_rows;
echo $count;
$conn->close();
?>

please! all I want is get rid of the counts on the notification after the user open or read it. Thanks!

my database name = "messageTest" my database table = "messagetest" inside my table =

id notification status

最佳答案

如果您不想在没有未读值的情况下显示计数,则只需不显示即可。就这么简单。

if ($count > 0) {
echo $count;
} else {
// Do nothing
}

您可能还想考虑查看一些基本的编程教程。

关于PHP MYSQL,简单通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38859824/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com