how to alert message in php code example
Example 1: alert in php
$message = "Something";
echo "<script type='text/javascript'>alert('$message');</script>";
Example 2: how to build jquery messages notification with php and mysq
$sql = "update tbl_noti set status = 'read'";
$result = $conn->query($sql);
$row = $result->fetch_assoc();
$count = $result->num_rows;
echo $count;
$conn->close();
Example 3: how to build jquery messages notification with php and mysq
<script>
$(document).ready(function(){
function load_unseen_notification(view = '')
{
$.ajax({
url:"fetch.php",
method:"POST",
data:{view:view},
dataType:"json",
success:function(data)
{
$('.dropdown-menu').html(data.notification);
if(data.unseen_notification > 0)
{
$('.count').html(data.unseen_notification);
}
}
});
}
load_unseen_notification();
$('#comment_form').on('submit', function(event){
event.preventDefault();
if($('#subject').val() != '' && $('#comment').val() != '')
{
var form_data = $(this).serialize();
$.ajax({
url:"insert.php",
method:"POST",
data:form_data,
success:function(data)
{
$('#comment_form')[0].reset();
load_unseen_notification();
}
});
}
else
{
alert("Both Fields are Required");
}
});
$(document).on('click', '.dropdown-toggle', function(){
$('.count').html('');
load_unseen_notification('yes');
});
setInterval(function(){
load_unseen_notification();;
}, 5000);
});
</script>
Example 4: php pop up message
Copy Code<script Type="javascript">alert("JavaScript Alert Box by PHP")</script>
Example 5: php pop up message
Copy Code<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>JavaScript Alert Box by PHP</title>
<script type="text/javascript"> function openulr(newurl) { if (confirm("Are you sure you want to open new URL")) { document.location = newurl; }}</script></head>
<body>
<strong><a href="javascript:openulr('newurl.html');">Open new URL</a></strong>
</body>
</html>