<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Bootstrap Subscribe Newsletter Form inside Modal</title>
<link href="https://fonts.googleapis.com/css?family=Roboto|Varela+Round" rel="stylesheet">
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<style type="text/css">
body {
font-family: 'Varela Round', sans-serif;
}
.modal-newsletter {
color: #999;
font-size: 15px;
}
.modal-newsletter .modal-content {
padding: 40px;
border-radius: 0;
border: none;
}
.modal-newsletter .modal-header {
border-bottom: none;
position: relative;
text-align: center;
border-radius: 5px 5px 0 0;
}
.modal-newsletter h4 {
color: #000;
text-align: center;
font-size: 30px;
margin: 0 0 25px;
font-weight: bold;
text-transform: capitalize;
}
.modal-newsletter .close {
background: #c0c3c8;
position: absolute;
top: -15px;
right: -15px;
color: #fff;
text-shadow: none;
opacity: 0.5;
width: 22px;
height: 22px;
border-radius: 20px;
font-size: 16px;
}
.modal-newsletter .close span {
position: relative;
top: -1px;
}
.modal-newsletter .close:hover {
opacity: 0.8;
}
.modal-newsletter .form-control, .modal-newsletter .btn {
min-height: 46px;
border-radius: 3px;
}
.modal-newsletter .form-control {
box-shadow: none;
border-color: #dbdbdb;
}
.modal-newsletter .form-control:focus {
border-color: #19bc9c;
box-shadow: 0 0 8px rgba(114, 101, 234, 0.5);
}
.modal-newsletter .btn {
color: #fff;
border-radius: 4px;
background: #19bc9c;
text-decoration: none;
transition: all 0.4s;
line-height: normal;
padding: 6px 20px;
min-width: 150px;
border: none;
}
.modal-newsletter .btn:hover, .modal-newsletter .btn:focus {
background: #4e3de4;
outline: none;
}
.modal-newsletter .input-group {
margin: 30px 0 15px;
}
.hint-text {
margin: 100px auto;
text-align: center;
}
</style>
<script type="text/javascript">
$(document).ready(function(){
$("#myModal").modal('show');
});
</script>
<div id="myModal" class="modal fade">
<div class="modal-dialog modal-newsletter">
<div class="modal-content">
<form action="confirmation.php" method="post">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true"><span>×</span></button>
</div>
<div class="modal-body text-center">
<h4>Subscribe to our newsletter</h4>
<p>Sugnup for our weekly newsletter to get the latest news, updates and amazong offers delivered direcly in your inbox.</p>
<div class="input-group">
<input type="email" class="form-control" placeholder="Enter your email" required>
<span class="input-group-btn">
<input type="submit" class="btn btn-primary" value="Subscribe">
</span>
</div>
</div>
</form>
</div>
</div>
</div>
<p class="hint-text"><strong>Note:</strong> Refresh the page or run the code to reload the modal.</p>
</body>
</html>
Cairo-Coders is the one place for high quality web development, Web Design and software development tutorials and Resources programming. Learn cutting edge techniques in web development, design and software development, download source components and participate in the community.
Bootstrap Subscribe Newsletter Form inside Modal
Bootstrap Subscribe Newsletter Form inside Modal
PHP Month Array List Select Box Live-search
PHP Month Array List Select Box Live-search
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>PHP Month Array List Select Box Live-search</title>
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.6.3/css/bootstrap-select.min.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.6.3/js/bootstrap-select.min.js"></script>
</head>
<body>
<div class="container">
<div class="row">
<h2>PHP Month Array List Select Box Live-search</h2>
<p>This uses <a href="https://silviomoreto.github.io/bootstrap-select/">https://silviomoreto.github.io/bootstrap-select/</a></p>
<hr />
</div>
<?php
$lang_Date = array(
'Jan' =>'January',
'Feb' =>'February',
'Mar' =>'March',
'Apr' =>'April',
'May' =>'May',
'June' =>'June',
'July' =>'July',
'August' =>'August',
'Sep' =>'September',
'Oct' =>'October',
'Nov' =>'November',
'Dec' =>'December',
);
?>
<div class="row-fluid">
<select class="selectpicker" data-show-subtext="true" data-live-search="true">
<?php
foreach ($lang_Date as $key=>$value){
$selected = ($key==$function)?" Selected=\"Selected\"": "";
echo "<option data-subtext=\"$key\" $selected > $value </option>";
}
?>
</select>
<span class="help-inline">Try searching for November</span>
</div>
</div>
</body>
</html>
How to create a Jquery Ajax Mysqli Pagenation
Jquery Ajax Pagenation
Create Database table
CREATE TABLE IF NOT EXISTS `paginate` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(60) NOT NULL,
`message` text NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=51 ;
Create Database table
CREATE TABLE IF NOT EXISTS `paginate` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(60) NOT NULL,
`message` text NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=51 ;
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Jquery ajax pagenation</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$("#results").load("fetch_pages.php", {'page':1} ); //initial page number to load
$(".paginate_click").click(function (e) {
$("#results").prepend('<div class="loading-indication"><img src="img/ajax-loader.gif" /> Loading...</div>');
var page_num = $(this).text(); //get page number from the clicked element
$('.paginate_click').removeClass('active'); //remove any active class
//post page number and load returned data into result element
$("#results").load("fetch_pages.php", {'page': page_num}, function(){
});
$(this).addClass('active'); //add active class to currently clicked element
return false; //prevent going to herf link
});
});
</script>
</head>
<body>
<?php
include("config.inc.php");
$results = mysqli_query($connecDB,"SELECT COUNT(*) FROM paginate");
$get_total_rows = mysqli_fetch_array($results); //total records
//break total records into pages
$pages = ceil($get_total_rows[0]/$item_per_page);
//create pagination
if($pages > 1)
{
$pagination = '';
$pagination .= '<ul class="paginate">';
for($i = 1; $i<$pages; $i++)
{
$pagination .= '<li><a href="#" class="paginate_click">'.$i.'</a></li>';
}
$pagination .= '</ul>';
}
?>
<p><h1 align="center">How to create a Jquery Ajax Pagenation</h1></p>
<div id="results"></div>
<?php echo $pagination; ?>
<style>
.paginate {
padding: 0px;
margin: 0px;
height: 30px;
display: block;
text-align: center;
}
.paginate li {
display: inline-block;
list-style: none;
padding: 0px;
margin-right: 1px;
width: 30px;
text-align: center;
background: #4CC2AF;
line-height: 25px;
}
.paginate .active {
display: inline-block;
list-style: none;
padding: 0px;
margin-right: 1px;
width: 30px;
text-align: center;
line-height: 25px;
background-color: #666666;
}
.paginate li a{
color:#FFFFFF;
text-decoration:none;
}
#results{
font: 12px Arial, Helvetica, sans-serif;
width: 400px;
margin-left: auto;
margin-right: auto;
}
.page_result{
padding: 0px;
}
.page_result li{
background: #E4E4E4;
margin-bottom: 5px;
padding: 10px;
font-size: 12px;
list-style: none;
}
.page_result .page_name {
font-size: 14px;
font-weight: bold;
margin-right: 5px;
}
#results .loading-indication{
background:#FFFFFF;
padding:10px;
position: absolute;
}
</style>
</body>
</html>
//config.inc.php
<?php
$db_username = 'root';
$db_password = '';
$db_name = 'test';
$db_host = 'localhost';
$item_per_page = 5;
$connecDB = mysqli_connect($db_host, $db_username, $db_password,$db_name)or die('could not connect to database');
?>
//fetch_pages.php
<?php
include("config.inc.php");
//sanitize post value
$page_number = filter_var($_POST["page"], FILTER_SANITIZE_NUMBER_INT, FILTER_FLAG_STRIP_HIGH);
//validate page number is really numaric
if(!is_numeric($page_number)){die('Invalid page number!');}
//get current starting point of records
$position = ($page_number * $item_per_page);
//Limit our results within a specified range.
$results = mysqli_query($connecDB,"SELECT id,name,message FROM paginate ORDER BY id DESC LIMIT $position, $item_per_page");
//output results from database
echo '<ul class="page_result">';
while($row = mysqli_fetch_array($results))
{
echo '<li id="item_'.$row["id"].'"><span class="page_name">'.$row["name"].'</span><span class="page_message">'.$row["message"].'</span></li>';
}
echo '</ul>';
?>
jQuery PHP checkbox values to PHP $_POST variables
jQuery PHP checkbox values to PHP $_POST variables
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>jQuery PHP checkbox values to PHP $_POST variables</title>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script type = "text/javascript">
$(document).ready(function () {
$('#submitBtn').click (function() {
var selected = new Array();
$("input:checkbox[name=programming]:checked").each(function() {
selected.push($(this).val());
});
var selectedString = selected.join(",");
$.post("ajaxcheckboxvalue.php", {selected: selected },
function(data){
$('.result').html(data);
});
});
});
</script>
</head>
<body>
<div class="container">
<div class="row">
<div class="col-md-6 offset-md-3">
<h1>jQuery PHP checkbox values to PHP $_POST variables</h1>
<div class="card" style="margin:50px 0">
<div class="card-header">Checkbox Animation</div>
<ul class="list-group list-group-flush">
<li class="list-group-item">
Bootstrap Checkbox Default
<label class="checkbox">
<input type="checkbox" name="programming" value="Bootstrap Checkbox Default"/>
<span class="default"></span>
</label>
</li>
<li class="list-group-item">
Bootstrap Checkbox Primary
<label class="checkbox">
<input type="checkbox" name="programming" value="Bootstrap Checkbox Primary"/>
<span class="primary"></span>
</label>
</li>
<li class="list-group-item">
Bootstrap Checkbox Success
<label class="checkbox">
<input type="checkbox" name="programming" value="Bootstrap Checkbox Success"/>
<span class="success"></span>
</label>
</li>
<li class="list-group-item">
Bootstrap Checkbox Info
<label class="checkbox">
<input type="checkbox" name="programming" value="Bootstrap Checkbox Info"/>
<span class="info"></span>
</label>
</li>
<li class="list-group-item">
Bootstrap Checkbox Warning
<label class="checkbox">
<input type="checkbox" name="programming" value="Bootstrap Checkbox Warning"/>
<span class="warning"></span>
</label>
</li>
<li class="list-group-item">
Bootstrap Checkbox Danger
<label class="checkbox">
<input type="checkbox" name="programming" value="Bootstrap Checkbox Danger"/>
<span class="danger"></span>
</label>
</li>
</ul>
<div class = "result" style="padding:10px;"></div>
<button type="button" id = "submitBtn" class="btn btn-outline-success slideright" style="margin:10px;">Submit</button>
</div>
</div>
</div>
</div>
<style>
@keyframes check {0% {height: 0;width: 0;}
25% {height: 0;width: 10px;}
50% {height: 20px;width: 10px;}
}
.checkbox{background-color:#fff;display:inline-block;height:28px;margin:0 .25em;width:28px;border-radius:4px;border:1px solid #ccc;float:right}
.checkbox span{display:block;height:28px;position:relative;width:28px;padding:0}
.checkbox span:after{-moz-transform:scaleX(-1) rotate(135deg);-ms-transform:scaleX(-1) rotate(135deg);-webkit-transform:scaleX(-1) rotate(135deg);transform:scaleX(-1) rotate(135deg);-moz-transform-origin:left top;-ms-transform-origin:left top;-webkit-transform-origin:left top;transform-origin:left top;border-right:4px solid #fff;border-top:4px solid #fff;content:'';display:block;height:20px;left:3px;position:absolute;top:15px;width:10px}
.checkbox span:hover:after{border-color:#999}
.checkbox input{display:none}
.checkbox input:checked + span:after{-webkit-animation:check .8s;-moz-animation:check .8s;-o-animation:check .8s;animation:check .8s;border-color:#555}
.checkbox input:checked + .default:after{border-color:#444}
.checkbox input:checked + .primary:after{border-color:#2196F3}
.checkbox input:checked + .success:after{border-color:#8bc34a}
.checkbox input:checked + .info:after{border-color:#3de0f5}
.checkbox input:checked + .warning:after{border-color:#FFC107}
.checkbox input:checked + .danger:after{border-color:#f44336}
</style>
</body>
</html>
//ajaxcheckboxvalue.php
<?php
$selected = $_POST['selected'];
foreach ($selected as $value) {
echo $value . " <br/>";
}
?>
Password meter using Javascript
password meter using Javascript
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Password meter using javascript</title>
<script>
function passwordStrength(password)
{
var desc = new Array();
desc[0] = "Very Weak";
desc[1] = "Weak";
desc[2] = "Better";
desc[3] = "Medium";
desc[4] = "Strong";
desc[5] = "Strongest";
var score = 0;
//if password bigger than 6 give 1 point
if (password.length > 6) score++;
//if password has both lower and uppercase characters give 1 point
if ( ( password.match(/[a-z]/) ) && ( password.match(/[A-Z]/) ) ) score++;
//if password has at least one number give 1 point
if (password.match(/\d+/)) score++;
//if password has at least one special caracther give 1 point
if ( password.match(/.[!,@,#,$,%,^,&,*,?,_,~,-,(,)]/) ) score++;
//if password bigger than 12 give another 1 point
if (password.length > 12) score++;
document.getElementById("passwordDescription").innerHTML = desc[score];
document.getElementById("passwordStrength").className = "strength" + score;
}
</script>
</head>
<body>
<form method="post">
<h1>Password strength meter</h1>
<label for="pass">Password</label>
<input type="password" name="pass" id="pass" onkeyup="passwordStrength(this.value)" />
<label for="passwordStrength">Password strength</label>
<div id="passwordDescription">Password not entered</div>
<div id="passwordStrength" class="strength0"></div>
</form>
<style>
#passwordStrength
{
height:10px;
display:block;
float:left;
}
.strength0
{
width:250px;
background:#cccccc;
}
.strength1
{
width:50px;
background:#ff0000;
}
.strength2
{
width:100px;
background:#ff5f5f;
}
.strength3
{
width:150px;
background:#56e500;
}
.strength4
{
background:#4dcd00;
width:200px;
}
.strength5
{
background:#399800;
width:250px;
}
</style>
</body>
</html>
Dyanamic Drop down combo box using Ajax Get jquery in array
Dyanamic Drop down combo box using Ajax Get jquery ajax php in array
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Dyanamic Drop down combo box using Ajax Get jquery in array</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<link rel='stylesheet' href='https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css'>
<script type="text/javascript">
jQuery(document).ready(function(){
jQuery("select[name='country']").change(function(){
var optionValue = jQuery("select[name='country']").val();
jQuery.ajax({
type: "GET",
url: "data.php",
data: "country="+optionValue+"&status=1",
beforeSend: function(){ jQuery("#ajaxLoader").show(); },
complete: function(){ jQuery("#ajaxLoader").hide(); },
success: function(response){
jQuery("#cityAjax").html(response);
jQuery("#cityAjax").show();
}
});
});
});
</script>
</head>
<body>
<h2>Dyanamic Drop down combo box using Ajax Get jquery ajax php in array</h2>
<h1>Countries:</h1>
<div class="box" style="position: absolute;top: 50%;left: 50%;">
<select name="country">
<option value="">Please Select</option>
<option value="1">Nepal</option>
<option value="2">India</option>
<option value="3">China</option>
<option value="4">USA</option>
<option value="5">UK</option>
<option value="6">Philippines</option>
</select>
</div>
<div id="ajaxLoader" style="display:none"><img src="../img/loader.gif" alt="loading...">Loading...</div>
<div id="cityAjax" style="display:none"></div>
<style>
body {
margin: 0;font-family: Arial;
padding: 0;
background-color: #004882;
}
h1 {
position: absolute;
top: 35%; color:#fff;
left:41%;
}
h2 {
color:#fff;padding:10px;text-align:center;
}
.box {
transform: translate(-50%, -50%);
}
.box select {
background-color: #0563af;
color: white;
padding: 12px;
width: 250px;
border: none;
font-size: 20px;
box-shadow: 0 5px 25px rgba(0, 0, 0, 0.2);
-webkit-appearance: button;
appearance: button;
outline: none;
}
.box::before {
content: "\f13a";
font-family: FontAwesome;
position: absolute;
top: 0;
right: 0;
width: 20%;
height: 100%;
text-align: center;
font-size: 28px;
line-height: 45px;
color: rgba(255, 255, 255, 0.5);
background-color: rgba(255, 255, 255, 0.1);
pointer-events: none;
}
.box:hover::before {
color: rgba(255, 255, 255, 0.6);
background-color: rgba(255, 255, 255, 0.2);
}
.box select option {
padding: 30px;
}
#ajaxLoader {
position: absolute;
top: 25%; color:#fff;
left:41%;
}
.city {
position: absolute;
top: 55%; color:#fff;
left:41%;
}
</style>
</body>
</html>
//data.php
<?php
$country = $_GET['country'];
if(!$country) {
return false;
}
$cities = array(
1 => array('Kathmandu','Bhaktapur','Patan','Pokhara','Lumbini'),
2 => array('Delhi','Mumbai','Kolkata','Bangalore','Hyderabad','Pune','Chennai','Jaipur','Goa'),
3 => array('Beijing','Chengdu','Lhasa','Macau','Shanghai'),
4 => array('Los Angeles','New York','Dallas','Boston','Seattle','Washington','Las Vegas'),
5 => array('Birmingham','Bradford','Cambridge','Derby','Lincoln','Liverpool','Manchester'),
6 => array('Olongapo City','Angeles City','Manila City','Davao City','Cebu City','Makati City','Pasay City')
);
$currentCities = $cities[$country];
?>
<h1 class="city">City:</h1>
<div class="box" style="position: absolute;top: 70%;left: 50%;">
<select name="city">
<option value="">Please Select</option>
<?php
foreach($currentCities as $city) {
?>
<option value="<?php echo $city; ?>"><?php echo $city; ?></option>
<?php
}
?>
</select>
</div>
jQuery CSS Popup modal
jQuery - Popup
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>jQuery Popup modal</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
var popupStatus = 0;
//loading popup with jQuery magic!
function loadPopup(){
//loads popup only if it is disabled
if(popupStatus==0){
$("#backgroundPopup").css({
"opacity": "0.7"
});
$("#backgroundPopup").fadeIn("slow");
$("#popupContact").fadeIn("slow");
popupStatus = 1;
}
}
//centering popup
function centerPopup(){
//request data for centering
var windowWidth = document.documentElement.clientWidth;
var windowHeight = document.documentElement.clientHeight;
var popupHeight = $("#popupContact").height();
var popupWidth = $("#popupContact").width();
//centering
$("#popupContact").css({
"position": "absolute",
"top": windowHeight/2-popupHeight/2,
"left": windowWidth/2-popupWidth/2
});
}
//disabling popup with jQuery magic!
function disablePopup(){
//disables popup only if it is enabled
if(popupStatus==1){
$("#backgroundPopup").fadeOut("slow");
$("#popupContact").fadeOut("slow");
popupStatus = 0;
}
}
//CONTROLLING EVENTS IN jQuery
$(document).ready(function(){
//LOADING POPUP
//Click the button event!
$("#button").click(function(){
//centering with css
centerPopup();
//load popup
loadPopup();
});
//CLOSING POPUP
//Click the x event!
$("#popupContactClose").click(function(){
disablePopup();
});
//Click out event!
$("#backgroundPopup").click(function(){
disablePopup();
});
//Press Escape event!
$(document).keypress(function(e){
if(e.keyCode==27 && popupStatus==1){
disablePopup();
}
});
});
</script>
</head>
<body>
<p><h1 align="center">jQuery Popup Modal</h1></p>
<div id="button"><input type="submit" value="PopUp!" /></div>
<div id="popupContact">
<a id="popupContactClose"><img src="../img/delete00.png"></a>
<h1>Title!</h1>
<p>Pellentesque viverra vulputate enim. Aliquam erat volutpat. Pellentesque tristique ante ut risus. Quisque dictum. Integer nisl </p>
<p>risus, sagittis convallis, rutrum id, elementum congue, nibh. Suspendisse dictum porta lectus. Donec placerat odio vel elit. Nullam ante </p>
<p>orci, pellentesque eget, tempus quis, ultrices in, est. Curabitur sit amet nulla.</p>
</div>
<div id="backgroundPopup"></div>
<style>
body{
background:#fff none repeat scroll 0%;
line-height:1;
font-size: 12px;
font-family:arial,sans-serif;
margin:0pt;
height:100%;
}
a{
cursor: pointer;
text-decoration:none;
}
#button{
text-align:center;
margin:100px;
}
#backgroundPopup{
display:none;
position:fixed;
height:100%;
width:100%;
top:0;
left:0;
background:#000000;
border:1px solid #cecece;
z-index:1;
}
#popupContact{
display:none;
position:fixed;
height:300px;
width:400px;
background:#FFFFFF;
border:2px solid #cecece;
z-index:2;
padding:12px;
font-size:13px;
}
#popupContact h1{
text-align:left;
color:#6FA5FD;
font-size:22px;
font-weight:700;
border-bottom:1px dotted #D3D3D3;
padding-bottom:2px;
margin-bottom:20px;
}
#popupContactClose{
font-size:14px;
line-height:14px;
right:6px;
top:4px;
position:absolute;
color:#6fa5fd;
font-weight:700;
display:block;
}
</style>
</body>
</html>
Jquery CSS Notification Boxes
Jquery Notification Boxes
Download Source Code and Images
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Jquery Notification Boxes</title>
<link rel="stylesheet" type="text/css" href="css/style.css"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
$(document).ready(function() {
$('.notification').hover(function() {
$(this).css('cursor','pointer');
}, function() {
$(this).css('cursor','auto');
});
$('.notification span').click(function() {
$(this).parents('.notification').fadeOut(800);
});
$('.notification').click(function() {
$(this).fadeOut(800);
});
});
</script>
</head>
<body>
<h1>Notification Boxes</h1>
<div class="notification success">
<span></span>
<div class="text">
<p><strong>Success!</strong> This is a success notification. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla varius eros et risus suscipit vehicula.</p>
</div>
</div>
<div class="notification warning">
<span></span>
<div class="text">
<p><strong>Warning!</strong> This is a warning notification. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla varius eros et risus suscipit vehicula.</p>
</div>
</div>
<div class="notification tip">
<span></span>
<div class="text">
<p><strong>Quick Tip!</strong> This is a quick tip notification. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla varius eros et risus suscipit vehicula.</p>
</div>
</div>
<div class="notification error">
<span></span>
<div class="text">
<p><strong>Error!</strong> This is a error notification. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla varius eros et risus suscipit vehicula.</p>
</div>
</div>
<div class="notification secure">
<span></span>
<div class="text">
<p><strong>Secure Area!</strong> This is a secure area notification. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla varius eros et risus suscipit vehicula.</p>
</div>
</div>
<div class="notification info">
<span></span>
<div class="text">
<p><strong>Info!</strong> This is a info notification. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla varius eros et risus suscipit vehicula.</p>
</div>
</div>
<div class="notification message">
<span></span>
<div class="text">
<p><strong>Message!</strong> This is a message notification. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla varius eros et risus suscipit vehicula.</p>
</div>
</div>
<div class="notification download">
<span></span>
<div class="text">
<p><strong>Download!</strong> This is a download notification. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla varius eros et risus suscipit vehicula.</p>
</div>
</div>
<div class="notification purchase">
<span></span>
<div class="text">
<p><strong>Purchase!</strong> This is a purchase notification. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla varius eros et risus suscipit vehicula.</p>
</div>
</div>
<div class="notification print">
<span></span>
<div class="text">
<p><strong>Print!</strong> This is a print notification. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla varius eros et risus suscipit vehicula.</p>
</div>
</div>
</body>
</html>
//css/style.css
body {
margin: 70px;
padding: 0;
background: #e5e5e5;
}
#new {
margin-bottom: 20px;
}
h1 {
font-family: Arial, Helvetica, sans-serif;
font-size: 18px;
font-style: normal;
font-weight: bold;
color: #323232;
margin: 50px;
}
/*NOTIFICATION BOX - NO DESCRIPTION */
.notification {
min-height: 70px;
width: 580px;
display: block;
position: relative;
/*Border Radius*/
border-radius: 5px;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
/*Box Shadow*/
-moz-box-shadow: 2px 2px 2px #cfcfcf;
-webkit-box-shadow: 2px 2px 4px #cfcfcf;
box-shadow: 2px 2px 2px #cfcfcf;
margin-bottom: 30px;
}
.notification span {
background: url(../images/close.png) no-repeat right top;
display: block;
width: 19px;
height: 19px;
position: absolute;
top:-9px;
right: -8px;
}
.notification .text {
overflow: hidden;
}
.notification p {
width: 500px;
font-family: Arial, Helvetica, sans-serif;
color: #323232;
font-size: 14px;
line-height: 21px;
text-align: justify;
float: right;
margin-right: 15px;
/* TEXT SHADOW */
text-shadow: 0px 0px 1px #f9f9f9;
}
/*SUCCESS BOX*/
.success {
border-top: 1px solid #edf7d0;
border-bottom: 1px solid #b7e789;
/*Background Gradients*/
background: #dff3a8;
background: -moz-linear-gradient(top,#dff3a8,#c4fb92);
background: -webkit-gradient(linear, left top, left bottom, from(#dff3a8), to(#c4fb92));
}
.success:before {
content: url(../images/success.png);
float: left;
margin: 23px 15px 0px 15px;
}
.success strong {
color: #61b316;
margin-right: 15px;
}
/*WARNING BOX*/
.warning {
border-top: 1px solid #fefbcd;
border-bottom: 1px solid #e6e837;
/*Background Gradients*/
background: #feffb1;
background: -moz-linear-gradient(top,#feffb1,#f0f17f);
background: -webkit-gradient(linear, left top, left bottom, from(#feffb1), to(#f0f17f));
}
.warning:before {
content: url(../images/warning.png);
float: left;
margin: 15px 15px 0px 25px;
}
.warning strong {
color: #e5ac00;
margin-right: 15px;
}
/*QUICK TIP BOX*/
.tip {
border-top: 1px solid #fbe4ae;
border-bottom: 1px solid #d9a87d;
/*Background Gradients*/
background: #f9d9a1;
background: -moz-linear-gradient(top,#f9d9a1,#eabc7a);
background: -webkit-gradient(linear, left top, left bottom, from(#f9d9a1), to(#eabc7a));
}
.tip:before {
content: url(../images/tip.png);
float: left;
margin: 20px 15px 0px 15px;
}
.tip strong {
color: #b26b17;
margin-right: 15px;
}
/*ERROR BOX*/
.error {
border-top: 1px solid #f7d0d0;
border-bottom: 1px solid #c87676;
/*Background Gradients*/
background: #f3c7c7;
background: -moz-linear-gradient(top,#f3c7c7,#eea2a2);
background: -webkit-gradient(linear, left top, left bottom, from(#f3c7c7), to(#eea2a2));
}
.error:before {
content: url(../images/error.png);
float: left;
margin: 20px 15px 0px 15px;
}
.error strong {
color: #b31616;
margin-right: 15px;
}
/*SECURE AREA BOX*/
.secure {
border-top: 1px solid #efe0fe;
border-bottom: 1px solid #d3bee9;
/*Background Gradients*/
background: #e5cefe;
background: -moz-linear-gradient(top,#e5cefe,#e4bef9);
background: -webkit-gradient(linear, left top, left bottom, from(#e5cefe), to(#e4bef9));
}
.secure:before {
content: url(../images/secure.png);
float: left;
margin: 18px 15px 0px 15px;
}
.secure strong {
color: #6417b2;
margin-right: 15px;
}
/*INFO BOX*/
.info {
border-top: 1px solid #f3fbff;
border-bottom: 1px solid #bedae9;
/*Background Gradients*/
background: #e0f4ff;
background: -moz-linear-gradient(top,#e0f4ff,#d4e6f0);
background: -webkit-gradient(linear, left top, left bottom, from(#e0f4ff), to(#d4e6f0));
}
.info:before {
content: url(../images/info.png);
float: left;
margin: 18px 15px 0px 21px;
}
.info strong {
color: #177fb2;
margin-right: 15px;
}
/*MESSAGE BOX*/
.message {
border-top: 1px solid #f4f4f4;
border-bottom: 1px solid #d7d7d7;
/*Background Gradients*/
background: #f0f0f0;
background: -moz-linear-gradient(top,#f0f0f0,#e1e1e1);
background: -webkit-gradient(linear, left top, left bottom, from(#f0f0f0), to(#e1e1e1));
}
.message:before {
content: url(../images/message.png);
float: left;
margin: 25px 15px 0px 15px;
}
.message strong {
color: #323232;
margin-right: 15px;
}
/*DONWLOAD BOX*/
.download {
border-top: 1px solid #ffffff;
border-bottom: 1px solid #eeeeee;
/*Background Gradients*/
background: #f7f7f7;
background: -moz-linear-gradient(top,#f7f7f7,#f0f0f0);
background: -webkit-gradient(linear, left top, left bottom, from(#f7f7f7), to(#f0f0f0));
}
.download:before {
content: url(../images/download.png);
float: left;
margin: 16px 15px 0px 18px;
}
.download strong {
color: #037cda;
margin-right: 15px;
}
/*PURCHASE BOX*/
.purchase {
border-top: 1px solid #d1f7f8;
border-bottom: 1px solid #8eabb1;
/*Background Gradients*/
background: #c4e4e4;
background: -moz-linear-gradient(top,#c4e4e4,#97b8bf);
background: -webkit-gradient(linear, left top, left bottom, from(#c4e4e4), to(#97b8bf));
}
.purchase:before {
content: url(../images/purchase.png);
float: left;
margin: 19px 15px 0px 15px;
}
.purchase strong {
color: #426065;
margin-right: 15px;
}
/*PRINT BOX*/
.print {
border-top: 1px solid #dde9f3;
border-bottom: 1px solid #8fa6b2;
/*Background Gradients*/
background: #cfdde8;
background: -moz-linear-gradient(top,#cfdde8,#9eb3bd);
background: -webkit-gradient(linear, left top, left bottom, from(#cfdde8), to(#9eb3bd));
}
.print:before {
content: url(../images/print.png);
float: left;
margin: 19px 15px 0px 15px;
}
.print strong {
color: #3f4c6b;
margin-right: 15px;
}
Download Source Code and Images
Jquery Ajax PHP and Mysqli Search Box
Jquery Ajax PHP and Mysqli Search Box
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Jquery Ajax PHP and Mysqli Search Box</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script type="text/javascript">
$(function() {
$(".search_button").click(function() {
var search_word = $("#search_box").val();
var dataString = 'search_word='+ search_word;
if(search_word==''){
}else{
$.ajax({
type: "GET",
url: "searchdata.php",
data: dataString,
cache: false,
beforeSend: function(html) {
document.getElementById("insert_search").innerHTML = '';
$("#flash").show();
$("#searchword").show();
$(".searchword").html(search_word);
$("#flash").html('<img src="img/loader.gif" align="absmiddle"> Loading Results...');
},
success: function(html){
$("#insert_search").show();
$("#insert_search").append(html);
$("#flash").hide();
}
});
}
return false;
});
});
</script>
</head>
<body>
<div align="center">
<div style="width:700px">
<div style="margin-top:20px; text-align:left">
<p align="center"><h1>Jquery Ajax PHP and Mysqli Search Box</h1></p>
<form method="get" action="">
<input type="text" name="search" id="search_box" class='search_box'/>
<input type="submit" value="Search" class="search_button" /><br />
<span style="color:#666666; font-size:14px; font-family:Arial, Helvetica, sans-serif;"><b>Ex :</b> Javascript</span>
</form>
</div>
<div>
<div id="searchword">Search results for <span class="searchword"></span></div>
<div id="flash"></div>
<ol id="insert_search" class="update"></ol>
</div>
</div>
</div>
<style>
body{
font-family:Arial, Helvetica, sans-serif;
}
a
{
color:#DF3D82;
text-decoration:none
}
a:hover
{
color:#DF3D82;
text-decoration:underline;
}
#search_box{
padding:3px; border:solid 1px #666666; width:400px; height:45px; font-size:18px;-moz-border-radius: 6px;-webkit-border-radius: 6px;
}
.search_button{
height:50px;border:#fe6f41 solid 1px; padding-left:9px;padding-right:9px;padding-top:9px;padding-bottom:9px; color:#000; font-weight:bold; font-size:16px;-moz-border-radius: 6px;-webkit-border-radius: 6px;
}
ol.update{
list-style:none;font-size:1.1em; margin-top:20px;padding-left:0;
}
#flash{
margin-top:20px;
text-align:left;
}
#searchword{
text-align:left; margin-top:20px; display:none;
font-family:Arial, Helvetica, sans-serif;
font-size:16px;
color:#000;
}
.searchword{
font-weight:bold;
color:#fe6f41;
}
ol.update li{ border-bottom:#dedede dashed 1px; text-align:left;padding-top:10px;padding-bottom:10px;}
ol.update li:first-child{ border-top:#dedede dashed 1px; text-align:left}
</style>
</body>
</html>
//searchdata.php
<?php
include"dbcon.php";
if(isset($_GET['search_word']))
{
$search_word=$_GET['search_word'];
$query = "SELECT * FROM tblprogramming WHERE title LIKE '%".$search_word."%' ORDER BY id DESC LIMIT 20";
$result = mysqli_query($conn, $query);
if(mysqli_num_rows($result) > 0) {
while($row = mysqli_fetch_array($result)){
$msg = $row["category"];
$title = $row["title"];
$bold_word='<b>'.$search_word.'</b>';
$final_msg = str_ireplace($search_word, $bold_word, $msg);
echo "<li>$title <br/><span style='font-size:12px;'>$final_msg</span></li>";
}
}else{
echo "<li>No Results</li>";
}
}
?>
//dbcon.php
<?php
$conn = new mysqli('localhost','root','','testingdb');
if ($conn->connect_error) {
die('Error : ('. $conn->connect_errno .') '. $conn->connect_error);
}
?>
Live Data Search using PHP MySqli and Jquery Ajax
Live Data Search using PHP MySqli and Jquery Ajax
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Live Data Search using PHP MySqli and Jquery Ajax</title>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
load_data();
function load_data(query)
{
$.ajax({
url:"ajaxlivesearch.php",
method:"POST",
data:{query:query},
success:function(data)
{
$('#result').html(data);
}
});
}
$('#search_text').keyup(function(){
var search = $(this).val();
if(search != ''){
load_data(search);
}else{
load_data();
}
});
});
</script>
</head>
<body>
<div class="container search-table">
<p><h2 align="center">Live Data Search using PHP MySqli and Jquery Ajax</h2></p>
<div class="search-box">
<div class="row">
<div class="col-md-3">
<h5>Search All Fields</h5>
</div>
<div class="col-md-9">
<input type="text" name="search_text" id="search_text" class="form-control" placeholder="Search all fields e.g. HTML">
</div>
</div>
</div>
<div id="result"></div>
</div>
<style>
.search-table{
padding: 10%;
margin-top: -6%;
}
.search-box{
background: #c1c1c1;
border: 1px solid #ababab;
padding: 3%;
}
.search-box input:focus{
box-shadow:none;
border:2px solid #eeeeee;
}
.search-list{
background: #fff;
border: 1px solid #ababab;
border-top: none;
}
.search-list h3{
background: #eee;
padding: 3%;color:#fe6f41;
margin-bottom: 0%;
}
</style>
</body>
</html>
//ajaxlivesearch.php
<div class="search-list">
<?php
include"dbcon.php";
$output = '';
if(isset($_POST["query"]))
{
$search = mysqli_real_escape_string($conn, $_POST["query"]);
$query = "SELECT * FROM tblprogramming WHERE title LIKE '%".$search."%' OR category LIKE '%".$search."%'";
}else{
$query = "SELECT * FROM tblprogramming ORDER BY id";
}
$result = mysqli_query($conn, $query);
if(mysqli_num_rows($result) > 0) {
$totalfound = mysqli_num_rows($result);
$output .= '<h3>'.$totalfound.' Records Found</h3>
<table class="table table-striped custab">
<thead>
<tr>
<th>Title</th>
<th>Category</th>
</tr>
</thead>
<tbody>';
while($row = mysqli_fetch_array($result))
{
$output .= '
<tr>
<td>'.$row["title"].'</td>
<td>'.$row["category"].'</td>
</tr>';
}
echo $output;
}else{
echo 'No Rocord Found';
}
?>
</tbody>
</table>
</div>
//dbcon.php
<?php
$conn = new mysqli('localhost','root','','testingdb');
if ($conn->connect_error) {
die('Error : ('. $conn->connect_errno .') '. $conn->connect_error);
}
?>
//tablebase table tblprogramming CREATE TABLE `tblprogramming` ( `id` int(11) NOT NULL, `title` varchar(250) NOT NULL, `category` varchar(255) NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1; -- -- Dumping data for table `tblprogramming` -- INSERT INTO `tblprogramming` (`id`, `title`, `category`) VALUES (1, 'HTML', 'Web Development'), (2, 'PHP', 'Web Development'), (3, 'C#', 'Programming Language'), (4, 'JavaScript', 'Web Development'), (5, 'Bootstrap', 'Web Design'), (6, 'Python', 'Programming Language'), (7, 'Android', 'App Development'), (8, 'Angular JS', 'Web Delopment'), (9, 'Java', 'Programming Language'), (10, 'Python Django', 'Web Development'), (11, 'Codeigniter', 'Web Development'), (12, 'Laravel', 'Web Development'), (13, 'Wordpress', 'Web Development');
How to get the values of Select All Checkbox using jQuery
How to get the values of Select All Checkbox using jQuery
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>How to get the values of Select All Checkbox using jQuery</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<SCRIPT language="javascript">
$(document).ready(function() {
// add multiple select / deselect functionality
$("#selectall").click(function () {
$('.item').attr('checked', this.checked);
});
// if all checkbox are selected, check the selectall checkbox and viceversa
$(".item").click(function(){
if($(".item").length == $(".item:checked").length) {
$("#selectall").attr("checked", "checked");
} else {
$("#selectall").removeAttr("checked");
}
});
//get the values of selected checkboxes
$("button").click(function(){
var favorite = [];
$.each($("input[name='programming']:checked"), function(){
favorite.push($(this).val());
});
alert("My favourite Programming are: " + favorite.join(", "));
});
});
</SCRIPT>
</head>
<body>
<form>
<p><h1>How to get the values of Select All Checkbox using jQuery</h1></p>
<label>Select your favorite programming <br/>
Select All Checkbox <input type="checkbox" id="selectall"/></label><br/>
<input type="checkbox" name="programming" class="item" value="Jquery"/>
Jquery<br/>
<input type="checkbox" name="programming" class="item" value="php mysql"/>
php mysql<br/>
<input type="checkbox" name="programming" class="item" value="3"/>
Java<br/>
<input type="checkbox" name="programming" class="item" value="4"/>
Javascript<br/>
<input type="checkbox" name="programming" class="item" value="5"/>
Python<br/>
<input type="checkbox" name="programming" class="item" value="6"/>
Ruby<br/>
<button type="button">Get Values</button>
</form>
</html>
Pagination with PHP and Mysqli
Pagination with PHP and Mysqli
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Pagination with PHP and Mysqli</title>
</head>
<body>
<div align="center" style="font-size:24px;color:#cc0000;font-weight:bold">Pagination with PHP and Mysqli</div>
<div id="container">
<?php
$page = (isset($_GET['page']))?$_GET['page']:'';
if ($page==''){
$page = "1";
}else{
$page = $_GET['page'];
}
include"dbcon.php";
$cur_page = $page;
$page -= 1;
$per_page = 11;
$previous_btn = true;
$next_btn = true;
$first_btn = true;
$last_btn = true;
$start = $page * $per_page;
$msg = "";
$query_pag_data = "SELECT * from country LIMIT $start, $per_page";
$result_pag_data = mysqli_query($conn, $query_pag_data);
while($row = mysqli_fetch_assoc($result_pag_data)) {
$htmlmsg=htmlentities($row['country']);
$msg .= "<li><b>" . $row['id'] . "</b> " . $htmlmsg . "</li>";
}
$msg = "<div class='data'><ul>" . $msg . "</ul></div>"; // Content for Data
$query_pag_num = mysqli_query($conn,"SELECT COUNT(*) AS mycount FROM country" ) or die(mysqli_error($this->dblink));
$res = mysqli_fetch_object($query_pag_num);
$count = $res->mycount;
$no_of_paginations = ceil($count / $per_page);
// ---------------Calculating the starting and endign values for the loop-----------------------------------
if ($cur_page >= 7) {
$start_loop = $cur_page - 3;
if ($no_of_paginations > $cur_page + 3)
$end_loop = $cur_page + 3;
else if ($cur_page <= $no_of_paginations && $cur_page > $no_of_paginations - 6) {
$start_loop = $no_of_paginations - 6;
$end_loop = $no_of_paginations;
} else {
$end_loop = $no_of_paginations;
}
} else {
$start_loop = 1;
if ($no_of_paginations > 7)
$end_loop = 7;
else
$end_loop = $no_of_paginations;
}
//-----------------------------------------------------------------------------------------------------------
$msg .= "<div class='pagination'><ul>";
// FOR ENABLING THE FIRST BUTTON
if ($first_btn && $cur_page > 1) {
$msg .= "<li p='1' class='active'><a href='?page=1'>First</a></li>";
} else if ($first_btn) {
$msg .= "<li p='1' class='inactive'><a href='?page=1'>First</a></li>";
}
// FOR ENABLING THE PREVIOUS BUTTON
if ($previous_btn && $cur_page > 1) {
$pre = $cur_page - 1;
$msg .= "<li p='$pre' class='active'><a href='?page=$pre'>Previous</a></li>";
} else if ($previous_btn) {
$msg .= "<li class='inactive'>Previous</li>";
}
for ($i = $start_loop; $i <= $end_loop; $i++) {
if ($cur_page == $i)
$msg .= "<li p='$i' style='color:#fff;background-color:#70BA4C;' class='active'><a href='?page=$i'>{$i}</a></li>";
else
$msg .= "<li p='$i' class='active'><a href='?page={$i}'>{$i}</a></li>";
}
// TO ENABLE THE NEXT BUTTON
if ($next_btn && $cur_page < $no_of_paginations) {
$nex = $cur_page + 1;
$msg .= "<li p='$nex' class='active'><a href='?page=$nex'>Next</a></li>";
} else if ($next_btn) {
$msg .= "<li class='inactive'>Next</li>";
}
// TO ENABLE THE END BUTTON
if ($last_btn && $cur_page < $no_of_paginations) {
$msg .= "<li p='$no_of_paginations' class='active'><a href='?page=$no_of_paginations'>Last</a></li>";
} else if ($last_btn) {
$msg .= "<li p='$no_of_paginations' class='inactive'><a href='?page=$no_of_paginations'>Last</a></li>";
}
$total_string = "<span class='total' a='$no_of_paginations'>Page <b>" . $cur_page . "</b> of <b>$no_of_paginations</b></span>";
$msg = $msg . "</ul>" . $total_string . "</div>"; // Content for pagination
echo $msg;
?>
</div>
<style type="text/css">
body{
width: 800px;
margin: 0 auto;
padding: 0;
}
a {text-decoration:none;}
#container {margin-bottom:20px;}
#container .data{
list-style-type: none;
margin: 0;
padding: 0;
}
#container .data ul li{
list-style: none;
background-color:lightyellow;
border:1px solid #FFDA5B;
padding:10px;
margin-bottom:5px;
}
#container .data ul li:hover{
background-color:#70BA4C;
border:1px solid #448B22;
}
#container .data ul li b {
-moz-border-radius:12px;
-webkit-border-radius:12px;
border-radius:32px;
background-color:#70BA4C;
border:1px solid #448B22;
color:#FFFFFF;padding:6px;margin-right:5px;
text-shadow:1px 1px 0 green;
}
#container .pagination ul li.inactive,
#container .pagination ul li.inactive:hover{
background-color:#ededed;
color:#bababa;
border:1px solid #bababa;
cursor: default;
}
#container .pagination{
width: 800px;
height: 25px;
}
#container .pagination ul li{
list-style: none;
float: left;
border: 1px solid #006699;
padding: 4px 8px 4px 8px;
margin: 0 3px 0 3px;
font-family: arial;
font-size: 14px;
color: #006699;
font-weight: bold;
background-color: #f2f2f2;
}
#container .pagination ul li:hover{
color: #fff;
background-color: #006699;
cursor: pointer;
}
.total
{
float:right;font-family:arial;color:#999;
}
</style>
</body>
</html>
//dbcon.php
<?php
$conn = new mysqli('localhost','root','','testingdb');
if ($conn->connect_error) {
die('Error : ('. $conn->connect_errno .') '. $conn->connect_error);
}
?>
Download SQL file Here
Create a PHP jQuery ajax and MySQLi LIKE Search
Create a PHP jQuery ajax and MySQLi LIKE Search
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Create a PHP jQuery ajax and MySQLi LIKE Search</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script>
<script type="text/javascript">
$(function() {
$(".search_button").click(function() {
// getting the value that user typed
var searchString = $("#search_box").val();
// forming the queryString
var data = 'search='+ searchString;
// if searchString is not empty
if(searchString) {
// ajax call
$.ajax({
type: "POST",
url: "do_search.php",
data: data,
beforeSend: function(html) { // this happens before actual call
$("#results").html('');
$("#searchresults").show();
$(".word").html(searchString);
},
success: function(html){ // this happens after we get results
$("#results").show();
$("#results").append(html);
}
});
}
return false;
});
});
</script>
</head>
<body>
<div id="container">
<div style="margin:20px auto; text-align: center;">
<form method="post" action="">
<input type="text" name="search" id="search_box" class='search_box'/>
<input type="submit" value="Search" class="search_button" /><br />
</form>
</div>
<div>
<div id="searchresults">Search results :</div>
<div id="results" class="update"></div>
</div>
</div>
<style>
body{ font-family:Arial, Helvetica, sans-serif; }
#container { margin: 0 auto; width: 600px; }
#search_box {
padding:4px;
border:solid 1px #666666;
width:300px;
height:30px;
font-size:18px;-moz-border-radius: 6px;-webkit-border-radius: 6px;
}
.search_button {
border:#000000 solid 1px;
padding: 6px;
color:#000;
font-weight:bold;
font-size:16px;-moz-border-radius: 6px;-webkit-border-radius: 6px;
}
#searchresults {
text-align:left;
margin-top:20px;
display:none;
font-family:Arial, Helvetica, sans-serif;
font-size:16px;
color:#000;
}
#newspaper-b {
font-family: lucida sans unicode,lucida grande,Sans-Serif;
font-size: 12px;
width: 480px;
text-align: left;
border-collapse: collapse;
border: 1px solid #69c;
margin: 20px;
}
.tr, tr {
border-bottom: 1px solid #ddd;
}
#newspaper-b th {
font-weight: 400;
font-size: 14px;
color: #039;
padding: 15px 10px 10px;
}
#newspaper-b tbody {
background: #e8edff;
}
#newspaper-b td {
color: #669;
border-top: 1px dashed #fff;
padding: 10px;
}
#newspaper-b tbody tr:hover td{color:#339;background:#d0dafd}
.found {
font-weight: bold;
font-style: italic;
color: #ff0000;
}
</style>
</body>
</html>
//do_search.php
<table id="newspaper-b">
<thead>
<tr>
<th scope="col">Name</th>
<th scope="col">Category</th>
<th scope="col">Price</th>
<th scope="col">Discount</th>
</tr>
</thead>
<tbody>
<?php
include("dbcon.php");
//if we got something through $_POST
if (isset($_POST['search'])) {
// never trust what user wrote! We must ALWAYS sanitize user input
$word = mysql_real_escape_string($_POST['search']);
$word = htmlentities($word);
// build your search query to the database
$sql = "SELECT * FROM product WHERE name LIKE '%" . $word . "%' ORDER BY pid LIMIT 10";
$result = mysqli_query($conn, $sql);
if (mysqli_num_rows($result) > 0) {
$end_result = '';
while($row = mysqli_fetch_assoc($result)) {
$rs_name = $row["name"];
$category = $row["category"];
$price = $row["price"];
$discount = $row["discount"];
$bold = '<span class="found">' . $word . '</span>';
$end_result .= '<tr><td>'. str_ireplace($word, $bold, $rs_name).'</td><td>'.$category.'</td><td>'.$price.'</td><td>'.$discount.'</td></tr>';
}
echo $end_result;
}else {
echo "0 results";
}
}
?>
</tbody>
</table>
//dbcon.php
<?php
$conn = new mysqli('localhost','root','','testingdb');
if ($conn->connect_error) {
die('Error : ('. $conn->connect_errno .') '. $conn->connect_error);
}
?>
Subscribe to:
Posts (Atom)









