Tagged: mysql and ajax

PHP AJAX Live Search Box Autocomplete Using MySQL Database 0

PHP AJAX Live Search Box Autocomplete Using MySQL Database

Today, We want to share with you PHP AJAX Live Search Box Autocomplete Using MySQL Database.In this post we will show you PHP Jquery AJAX Live Search Box Using MySQL, hear for PHP MySQL Live Search Box using Jquery Ajax Example we will give you demo and example for implement.In this post, we will learn about Jquery Ajax Live Search Box using PHP MySql with an example.

PHP AJAX Live Search Box Autocomplete Using MySQL Database

There are the Following The simple About PHP AJAX Live Search Box Autocomplete Using MySQL Database Full Information With Example and source code.

As I will cover this Post with live Working example to develop ajax live data search using jquery php mysql, so the some major files and Directory structures for this example is following below.

  • index.php
  • fetch.php

Step 1: Creating the Database Table

— Database: `member_list` >> — Table structure for table `member_tbl`

CREATE TABLE IF NOT EXISTS `member_tbl` (
  `MemberID` int(11) NOT NULL AUTO_INCREMENT,
  `MemberName` varchar(250) NOT NULL,
  `member_addr` text NOT NULL,
  `member_city` varchar(250) NOT NULL,
  `member_pcode` varchar(30) NOT NULL,
  `member_country` varchar(100) NOT NULL,
  PRIMARY KEY (`MemberID`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=14 ;

Step 2: Dumping data On Table

Dumping data for table `member_tbl`

//ajax live data search using jquery php mysql
INSERT INTO `member_tbl` (`MemberID`, `MemberName`, `member_addr`, `member_city`, `member_pcode`, `member_country`) VALUES
(1, 'Jaydeep Gondaliya', 'sejal Str. 57', 'Berlin', '12209', 'Germany'),
(2, 'Ankit Kathiriya', 'Avda. de la Ram park 2222', 'USA D.F.', '5021', 'USA'),
(3, 'Krunal Sisodiya', 'sardha 2312', 'USA D.F.', '5475', 'USA'),
(4, 'chirag dethariya', '120 dsp salon Sq.', 'London', 'WA1 1DP', 'UK'),
(5, 'Dhaval dave', 'Rua do Ganesh, 12', 'Resende', '56458-363', 'UEA'),
(6, 'Pooja solanki', 'ul. astha 68', 'Walla', '01-658', 'Poland'),
(7, 'Bhakti Banugariya', 'kavya 45', 'Helsinki', '2853', 'India'),
(8, 'Nilesh chandvadiya', '305 - 14th Ave. S. Suite 3B', 'Seattle', '98128', 'USA'),
(9, 'Hitesh Ajani', 'Rua do Ganesh, 12', 'Resende', '098952-363', 'UEA'),
(10, 'Mayur Dhameliya', 'bhakti 38', 'Oulu', '321452', 'India'),
(11, 'Stavan Patel', '2, rue du chandni', 'Reims', '350024', 'France'),
(12, 'Parag shukla', '722 Titupati Blvd.', 'Kirkland', '360002', 'USA'),
(13, 'Vijay bhanderi', 'Bhavanath. 48', 'Butte', '225010', 'USA');

Step 3: Creating the Search Form

index.php

This is where I will make a simple HTML form and PHP server side source code for our web application. To make the forms simply all souce code copy and write it into your any text editor Like Notepad++, then save file it as index.php.

 
  
  <title>PHP AJAX Live Search Box Autocomplete Using MySQL Database</title>
  
  
  
 
 
  <div class="pakainfo container">
   <br />
   <h2 align="center">PHP AJAX Live Search Box Autocomplete Using MySQL Database</h2>
   
   <b>Simple ajax live data search using jquery php mysql</b><br />
   <div class="pakainfo form-group">
    <div class="input-group pakainfo">
     <span class="input-group-addon pakainfo">Search</span>
     
    </div>
   </div>
   <br />
   <div id="result"></div>
  </div>
 


$(document).ready(function(){

 ajax_data_load();

 function ajax_data_load(query)
 {
  $.ajax({
   url:"fetch.php",
   method:"POST",
   data:{query:query},
   success:function(data)
   {
    $('#result').html(data);
   }
  });
 }
 $('#query_search').keyup(function(){
  var search = $(this).val();
  if(search != '')
  {
   ajax_data_load(search);
  }
  else
  {
   ajax_data_load();
  }
 });
});

Step 4 : Processing Search Query in Backend

fetch.php for PHP AJAX Live Search Box Autocomplete server side source code

 0)
{
 $output .= '
  <div class="pakainfo table-responsive">
   <table class="table table bordered">
    <tr>
     <th>Member Name</th>
     <th>member Address</th>
     <th>member_city</th>
     <th>Member Post Code</th>
     <th>member_country</th>
    </tr>
 ';
 while($memres = mysqli_fetch_array($result))
 {
  $output .= '
   <tr>
    <td>'.$memres["MemberName"].'</td>
    <td>'.$memres["member_addr"].'</td>
    <td>'.$memres["member_city"].'</td>
    <td>'.$memres["member_pcode"].'</td>
    <td>'.$memres["member_country"].'</td>
   </tr>
  ';
 }
 echo $output;
}
else
{
 echo 'Data Not Found';
}

?>

Angular 6 CRUD Operations Application Tutorials

Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about PHP AJAX Live Search Box Autocomplete Using MySQL Database.
I would like to have feedback on my Pakainfo.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Jquery Datatable listing json Server side in Php Mysql and Ajax 0

Jquery Datatable listing json Server side in Php Mysql and Ajax

Jquery Datatable listing json Server side in Php Mysql and Ajax

jQuery Datatable listing Example with JSON Data

In this Post We Will Explain About is Jquery Datatable listing json Server side in Php Mysql and Ajax With Example and Demo.Welcome on Pakainfo.com – Examples, The best For Learn web development Tutorials,Demo with Example! Hi Dear Friends here u can know to Example

In this post we will show you Best way to implement jQuery Datatables Example and Demos Using Rest WebService, hear for jQuery Datatable listing Example with JSON Datawith Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.

Inlcude External Lins

<link rel="stylesheet" href="bootstrap.min.css">
<script src="jquery.min.js"></script>
<script src="bootstrap.min.js"></script>
<link rel="stylesheet" type="text/css" href="datatables.min.css"/>
<script type="text/javascript" src="datatables.min.js"></script>

Markup part HTML(index.html)

<table id="mysmarttable">
	<thead>
		<tr>
			<th>Person ID</th>
			<th>Desc - Title</th>
			<th>Data Body</th>
		</tr>
	</thead>
	
</table>

Get ServerSide call using Angularjs Examples

var mylivearray = [];
	$.ajax({
		url: "http://jsonplaceholder.typicode.com/posts",
		async: false,
		dataType: 'json',
		success: function (data) {
			for (var ldata = 0, len = data.length; ldata < len; ldata++) {
				var mydesc = data[ldata].body;
				mylivearray.push([ data[ldata].userId, '<a href="https://pakainfo.com" target="_blank">'+data[ldata].title+'</a>', mydesc.substring(0, 12)]);
			}
		mytable(mylivearray);
		}
	});

Passed Simple formatted data to jquery datatables.

	
function mytable(rdata) {	
	//console.log(rdata);
	$('#mysmarttable').DataTable( {
		"aaData": rdata
	} );
}

aaData : This datatables property hold the simple json data for all data fill to table listing

.

Example 2 : jquery datatables ajax json example

$("#livedatatable").dataTable({
  "bServerSide": true,
  "sAjaxSource": "https://pakainfo.com/api/data_source.json",
  "aoColumns": [{
    "mData":"name",
    "sTitle": "your Site name"
  },{
    "mData": "url",
    "mRender": function ( url, type, full )  {
      return  '<a href="'+url+'">' + url + '</a>';
    }
  },{
    "mData": "editor.name"
  },{
    "mData": "editor.phone"
  },{
    "mData":"editor",
    "mRender": function(data){
      return data.email.join("<br>");
    }
  }]
});

Example

I hope you have Got What is jquery datatable Ajax crud server side Examples And how it works.I would Like to have FeadBack From My Blog(Pakainfo.com) readers.Your Valuable FeadBack,Any Question,or any Comments abaout This Article(Pakainfo.com) Are Most Always Welcome.

PHP Ajax Form Validation without page refresh 0

PHP Ajax Form Validation without page refresh

PHP Ajax Form Validation without page refresh

In this Post We Will Explain About is PHP Ajax Form Validation without page refresh With Example and Demo.Welcome on Pakainfo.com – Examples, The best For Learn web development Tutorials,Demo with Example! Hi Dear Friends here u can know to submit form using ajax without page refresh Example

In this post we will show you Best way to implement ajax contact form with validation, hear for php form validation example code download with Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.

Simple PHP Ajax Form Validation Example from scratch

Here, We will make PHP simple contact us form submit using html with php ajax source code bootstrap framework. When We simple click on “Send Comments” button it will simple call php file fire ajax post jquery send request and check check some validation and show display it as now on simple bellow source code preview. We will make two simple file following files for index.php, and do_submit.php and include scripts this example:

index.php

<!DOCTYPE html>
<html>
<head>
	<title>Pakainfo.com Php Ajax Form simple Validation Example</title>
	<script type="text/javascript" src="https://code.jquery.com/jquery-1.9.1.min.js"></script>
	<script type="text/javascript" src="script.js"></script>
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
</head>
<body>

<div class="container">
  <h1>Step By Step Php Ajax Form simple Validation Example</h1>
  <form role="form" id="contactForm" class="contact-form" data-toggle="validator" class="shake">
    <div class="alert alert-danger display-live-error" style="display: none">
    </div>
    <div class="form-group">
      <div class="controls">
        <input type="text" id="name" class="form-control" placeholder="Enter your Name">
      </div>
    </div>
    <div class="form-group">
      <div class="controls">
        <input type="email" class="email form-control" id="email" placeholder="Enter your Email" >
      </div>
    </div>
    <div class="form-group">
      <div class="controls">
        <input type="text" id="mail_sub" class="form-control" placeholder="Enter your Subject" >
      </div>
    </div>
    <div class="form-group">
      <div class="controls">
        <textarea id="comments" rows="7" placeholder="Enter your Massage" class="form-control"></textarea>
      </div>  
    </div>
    <button type="submit" id="submit" class="btn btn-success"><i class="fa fa-check"></i> Send Comments</button>
  </form>
</div>
</body>
</html>

script.js

<script type="text/javascript">
  $(document).ready(function() {
	//form submit live
      $('#submit').click(function(e){
        e.preventDefault();

        var name = $("#name").val();
        var email = $("#email").val();
        var mail_sub = $("#mail_sub").val();
        var comments = $("#comments").val();

        $.ajax({
            type: "POST",
            url: "/do_submit.php",
            dataType: "json",
            data: {name:name, email:email, mail_sub:mail_sub, comments:comments},
            success : function(data){
                if (data.code == "200"){
                    alert("Success: " +data.msg);
                } else {
                    $(".display-live-error").html("<ul>"+data.msg+"</ul>");
                    $(".display-live-error").css("display","block");
                }
            }
        });

      });
  });
</script>

do_submit.php

<?php

$live_comments_error = "";

/* Devloped by Pakainfo.com NAME */
if (empty($_POST["name"])) {
    $live_comments_error = "<li>Your Name is required</<li>";
} else {
    $name = $_POST["name"];
}

/* Devloped by Pakainfo.com EMAIL */
if (empty($_POST["email"])) {
    $live_comments_error .= "<li>Your Email is required</li>";
} else if(!filter_var($_POST["email"], FILTER_VALIDATE_EMAIL)) {
    $live_comments_error .= "<li>Invalid email format</li>";
}else {
    $email = $_POST["email"];
}

/*Devloped by Pakainfo.com MSG SUBJECT */
if (empty($_POST["mail_sub"])) {
    $live_comments_error .= "<li>Your Subject is required</li>";
} else {
    $mail_sub = $_POST["mail_sub"];
}

/*Devloped by Pakainfo.com MESSAGE */
if (empty($_POST["comments"])) {
    $live_comments_error .= "<li>Your Comments is required</li>";
} else {
    $comments = $_POST["comments"];
}

if(empty($live_comments_error)){
	$msg = "Your Name: ".$name.", Your Email: ".$email.", Your Subject: ".$mail_sub.", Your Comments:".$comments;
	echo json_encode(['code'=>200, 'msg'=>$msg]);
	exit;
}
//return form message 
echo json_encode(['code'=>404, 'msg'=>$live_comments_error]);

?>

You are Most welcome in my youtube Channel Please shubscibe my channel. and give me FeedBack.
More Details……
Angularjs Example

Example

I hope you have Got What is Simple PHP Ajax Form Validation Example from scratch And how it works.I would Like to have FeedBack From My Blog(Pakainfo.com) readers.Your Valuable FeedBack,Any Question,or any Comments about This Article(Pakainfo.com) Are Most Always Welcome.

Server-side Processing DataTables using PHP with MySQL 0

Server-side Processing DataTables using PHP with MySQL

Server-side Processing DataTables using PHP with MySQL

In this Post We Will Explain About is Server-side Processing DataTables using PHP with MySQL With Example and Demo.Welcome on Pakainfo.com – Examples, The best For Learn web development Tutorials,Demo with Example! Hi Dear Friends here u can know to DataTables Example – Server-side Processing with PHP Example

In this post we will show you Best way to implement jQuery Datatables Server Side Processing with PHP & MySQL, hear for DataTables – Server-side Processing in Codeigniter using Ajax with Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.

DataTables Server-side Processing using PHP with MySQL

DataTables is a one type of the jQuery External library used to Show the list of all Database records in a HTML View table with an dynamic interface.and then DataTables includes some more features like as a dataTable search, dataTable pagination, dataTable sort, dataTable filter and more dataTable features available.”DataTables Server-side”

Include External Libs

	<link rel="stylesheet"  href="datatables.min.css">	
	<link rel="stylesheet"  href="style.css">	
	<script src="jquery-1.11.2.min.js" type="text/javascript"></script>
    <script src="datatables.min.js" type="text/javascript"></script> 	

index.php

The following source code shows the HTML DataTable source code for the dynamic DataTable.

<body>
<div class="container">
	<table id="student-details" class="live-dt nowrap" cellspacing="0" width="100%">
	<thead>
		<tr>
		<th>Student First Name</th>
		<th>Student Last Name</th>
		<th>Student Address</th>
		<th>Student Phone</th>
		<th>Student DOB</th>
		</tr>
	</thead>
	</table>
	</div>
</body>

index.js

The following source code Display the jQuery based DataTable all the row initialization by setting custom the required some DataTable each property.and then It’s server Side PHP based property is set as Boolean value set like as a true and the server side PHP file path is some set specified for call the Ajax property.

// call do_server.php using jquery
$(document).ready(function() {
    $('#student-details').dataTable({
		"scrollX": true,
		"pagingType": "numbers",
        "processing": true,
        "serverSide": true,
        "ajax": "do_server.php"
    } );
} );

do_server.php

do_server.php files declares the database config setting configuration details store, student table name, all the columns and sends then to the simple external domain class to process the MySQL SELECT query.

<?php

//devloped by Pakainfo.com DB table to use
$db_table = 'tbl_contact';
 
//devloped by Pakainfo.com Table's primary key
$primaryKey = 'id';

$stud_data_col = array(
    array( 'db' => 'fname', 'dt' => 0 ),
    array( 'db' => 'lname',  'dt' => 1 ),
    array( 'db' => 'stud_address',   'dt' => 2 ),
    array( 'db' => 'stud_phone', 'dt' => 3,),
    array( 'db' => 'stud_date_of_birth','dt' => 4,
        'formatter' => function( $d, $row ) {
            return date( 'd-m-Y', strtotime($d));
        }
    )
   
);
 
//Live SQL server database connection information
$stud_details = array(
    'user' => 'live24u',
    'pass' => '[email protected]#dhk24u.com',
    'db'   => 'myclassstud',
    'host' => 'localhost'
);
 
//import external libs
require( 'vendor/datatables/ssp.class.php' );
 
echo json_encode(
    SSP::simple( $_GET, $stud_details, $db_table, $primaryKey, $stud_data_col )
);

style.css

.dataTables_wrapper .dataTables_paginate .paginate_button {
    color: #4D525B !important;	
    padding: 0.4em 0.8em;
    border: #4D525B 2px solid;;
}
.dataTables_wrapper .dataTables_paginate .paginate_button.current, .dataTables_wrapper .dataTables_paginate .paginate_button.current:hover {
    color: #3d3d3d !important;
	background: unset !important;
	border: #4D525B 2px solid !important;
    background-color: #4D525B !important;
	cursor: default;
}
table.dataTable.row-border tbody th, table.dataTable.row-border tbody td, table.dataTable.live-dt tbody th, table.dataTable.live-dt tbody td {
    border: 2px solid #eee;
    border-left: none;
    border-top: none;
}
.dataTables_wrapper select,.dataTables_wrapper input 
{
	border:2px solid #eee;
	padding:0.4em;
}
.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
    color: #4D525B !important;
	border-color: #4D525B !important;
    background-color: #4D525B !important;
	background:unset;
}
table.dataTable.stripe tbody tr.odd, table.dataTable.live-dt tbody tr.odd {
    background-color: #3d3d3d;
}
table.dataTable.live-dt tbody tr.even>.sorting_1, table.dataTable.order-column.stripe tbody tr.even>.sorting_1 {
    background-color: #f3f3f3; 
}
table.dataTable.live-dt tbody tr.odd>.sorting_1, table.dataTable.order-column.stripe tbody tr.odd>.sorting_1 {
    background-color: #3d3d3d; 
}
table.dataTable thead th, table.dataTable thead td {
	border: 2px solid #eee;
    border-left: none;
}
table.dataTable.stripe tbody tr.even, table.dataTable.live-dt tbody tr.even {
    background-color: #f3f3f3;
}
.datatables_length{
	padding-bottom: 15px;
}
table.dataTable{
	border-left:2px solid #eee;
}

You are Most welcome in my youtube Channel Please subscribe my channel. and give me FeedBack.
More Details……
Angularjs Example

Example

I hope you have Got What is Server Side Processing DataTable with PHP and MySQL And how it works.I would Like to have Feed Back From My Blog(Pakainfo.com) readers.Your Valuable Feed Back,Any Question,or any Comments about This Article(Pakainfo.com) Are Most Always Welcome.