Home » PHP Vue.js Live Search Box Using MySQL

PHP Vue.js Live Search Box Using MySQL

PHP Vue.js Live Search Box Using MySQL

In this Post We Will Explain About is PHP Vue.js Live Search Box Using 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 Live Search using Vue.js with PHP Example

In this post we will show you Best way to implement VueJS Ajax Live Search With PHP and MySQL, hear for VueJS Build Live Search Box Using PHP, MySQL And AJAX with Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.

Read Also:  How to fix the "jQuery or $ not defined WordPress" Issue in WordPress?

PHP Vue.js Live Search Box Using MySQL

In this Example,First of all Add or Include External Libs Like as a(jQuery, css etc..), and then create a simple index.php or index.html page.After that crate a simple javascript file like as a index.js or main.js, It is also add your web-application First Header Part to some priority set.After that Include your relevant CSS Class.

Creating Simple Database

CREATE TABLE `users` (
  `userfname` VARCHAR(30) NOT NULL,
  `userlname` VARCHAR(30) NOT NULL,
PRIMARY KEY(`userid`)

Inserting Data into our Database

INSERT INTO `users` (`userid`, `userfname`, `userlname`) VALUES
(1, 'krunal', 'sisodiya'),
(2, 'jaydeep', 'Gondaliya'),
(3, 'ankit', 'kathiriya'),
(4, 'chirag', 'Dethariya');


	<title>PHP Vue.js Live Search Box Using MySQL</title>

<div id="mymain">
	<div class="container">
		<h1 class="page-header text-center"></h1>
		<div class="col-xl-8 col-xl-offset-2">
			<div class="row">
				<div class="col-xl-4 col-xl-offset-8">
			<div style="height:15px"></div>
			<table class="table table-bordered table-striped">
					<th>USER Firstname</th>
					<th>USER Lastname</th>
							<td colspan="2" align="right">No user match your search</td>
						<td>{{ user.userfname }}</td>
						<td>{{ user.userlname }}</td>


var main = new Vue({
	el: '#mymain',
		users: [],
		search: {queryStr: ''},
		nouser: false
	mounted: function(){
		checkSearch: function() {
			var queryStr = main.toFormData(main.search);
	   		axios.post('do_action.php?do_action=search', queryStr)
					main.users = results.data.users;
					if(results.data.users == ''){
						main.nouser = true;
						main.nouser = false;
       	fetchUsers: function(){
					main.users = results.data.users;
		toFormData: function(obj){
			var liveForm = new FormData();
			for(var key in obj){
				liveForm.mainend(key, obj[key]);
			return liveForm;


connect_error) {
    die("Connection failed: " . $db_con->connect_error);
$output = array('error' => false);
	$sql = "select * from users";
	$query = $db_con->query($sql);
	$users = array();
	while($data_row = $query->fetch_array()){
		array_push($users, $data_row);
	$output['users'] = $users;
	$sql="select * from users where userfname like '%$queryStr%' or userlname like '%$queryStr%'";
	$query = $db_con->query($sql);
	$users = array();
	while($data_row = $query->fetch_array()){
		array_push($users, $data_row);
	$output['users'] = $users;

//return simple json format and data display 
header("Content-type: mainlication/json");
echo json_encode($output);

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

Read Also:  Javascript Autocomplete Address Using PHP With Demo


I hope you have Got What is How to Integrate live search in PHP and MySQL with VueJS 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.

Related FAQ

Here are some more FAQ related to this Article:

  1. Read Also:  Laravel Live Search Example Tutorial From Scratch
  2. Read Also:  Ajax PHP MySQL Creating Autocomplete Search Suggestion
  3. Read Also:  PHP Highlight search matching text Results with Mysql
  4. Read Also:  MySQL Remove special characters from database
  5. Read Also:  PHP Autocomplete Textbox using jQuery Example
  6. Read Also:  react open new tab on button click
  7. Read Also:  Date Filter Using Angular Example with Demo
  8. Read Also:  AngularJS Search Auto Suggestion box with PHP MySQLi
  9. Read Also:  Laravel 5.7 database Multiple seeder Example
  10. Read Also:  Google Like Autosuggest Search Using PHP Ajax

Leave a Comment

Your email address will not be published. Required fields are marked *