Topic: Mysqli

Insert Data Into Database using Vue.js with PHP Mysql 0

Insert Data Into Database using Vue.js with PHP Mysql

Insert Data Into Database using Vue.js with PHP Mysql

In this Post We Will Explain About is Insert Data Into Database using Vue.js with PHP 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 Insert Data into MySQL Database using PHP Example

In this post we will show you Best way to implement insert data into database in vuejs, hear for how to insert data in database using vuejs in php with Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.

Vue.js CRUD Operations with PHP and 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 Add Modal popup using vuejs

<!-- Vuejs simple Add Modal live24u-->
<div class="liveModal" v-if="displaySimpleModal">
	<div class="lstmodelctn">
		<div class="mdlheader">
			<span class="headerTitle">Add New User</span>
			<button class="closeBtn pull-left" @click="displaySimpleModal = false">×</button>
		</div>
		<div class="mdlBody">
			<div class="form-group live">
				<label>User Firstname:</label>
				<input type="text" class="form-control" v-model="newUser.userfname">
			</div>
			<div class="form-group live">
				<label>User Lastname:</label>
				<input type="text" class="form-control" v-model="newUser.userlname">
			</div>
		</div>
		<hr>
		<div class="mdlFooter">
			<div class="live footerBtn pull-left">
				<button class="live btn btn-default" @click="displaySimpleModal = false"><span class="glyphicon glyphicon-remove"></span> Cancel</button> <button class="btn btn-success live" @click="displaySimpleModal = false; saveUser();"><span class="live glyphicon glyphicon-floppy-disk"></span>USER Save</button>
			</div>
		</div>
	</div>
</div>

style.css

.liveModal{
	position:fixed;
	bottom:0;
	background: rgba(0, 0, 0, 0.4);
	top:0;
	left:0;
	left:0;
}
 
.lstmodelctn{
	width: 800px;
	background: #3d3d3d;
	margin:auto;
	margin-top:52px;
}
 
.mdlheader{
	font-size:20px;
	padding-left:14px;
	padding:12px;
	background: #008852;
	color: #FFFFFF;
	height:52px;
}
 
 
.mdlBody{
	padding:38px;
}
 
.mdlFooter{
	height:39px;
}
 
.footerBtn{
	margin-left:11px;
	margin-top:-9px;
}
 
.closeBtn{
	background: #c60000;
	color: #3d3d3d;
	border:none;
}

Updating index.php

<!DOCTYPE html>
<html>
<head>
	<title>Vue.js simple step by step CRUD Operation using PHP and MySQLi</title>
	<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
	<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div class="container">
	<h1 class="page-header text-center">simple Vue.js Insert update delete  Operation with PHP and MySQLi</h1>
	<div id="users">
		<div class="col-md-8 col-md-offset-2">
			<div class="row">
				<div class="col-md-12">
					<h2>User List
					<button class="btn btn-success pull-left" @click="displaySimpleModal = true"><span class="live glyphicon glyphicon-plus"></span> User</button>
					</h2>
				</div>
			</div>
 
			<div class="alert alert-danger text-center" v-if="msgError">
				<button type="button" class="close" @click="msgCls();"><span aria-hidden="true">×</span></button>
				<span class="live glyphicon glyphicon-alert"></span> {{ msgError }}
			</div>
 
			<div class="alert alert-success text-center" v-if="msgSuccess">
				<button type="button" class="close" @click="msgCls();"><span aria-hidden="true">×</span></button>
				<span class="live glyphicon glyphicon-ok"></span> {{ msgSuccess }}
			</div>
 
			<table class="table table-bordered table-striped">
				<thead>
					<th>User Firstname</th>
					<th>User Lastname</th>
					<th>User Action</th>
				</thead>
				<tbody>
					<tr v-for="user in users">
						<td>{{ user.userfname }}</td>
						<td>{{ user.userlname }}</td>
						<td>
							<button class="btn btn-success"><span class="live glyphicon glyphicon-edit"></span> Edit</button> <button class="btn btn-danger"><span class="live glyphicon glyphicon-trash"></span> Remove</button>
 
						</td>
					</tr>
				</tbody>
			</table>
		</div>
 
		<?php include('modal.php'); ?>
	</div>
</div>
<script src="vue.js"></script>
<script src="axios.js"></script>
<script src="main.js"></script>
</body>
</html>

Add API(api.php)

if($crud == 'create'){
 
	$userfname = $_POST['userfname'];
	$userlname = $_POST['userlname'];
 
	$sql = "insert into users (userfname, userlname) values ('$userfname', '$userlname')";
	$query = $conn->query($sql);
 
	if($query){
		$resOutput['message'] = "User Added Successfully";
	}
	else{
		$resOutput['error'] = true;
		$resOutput['message'] = "Could not add User";
	}
 
}

Updating our Vue source Code( main.js)

var main = new Vue({
	el: '#users',
	data:{
		displaySimpleModal: false,
		msgError: "",
		msgSuccess: "",
		users: [],
		newUser: {userfname: '', userlname: ''}
	},
 
	mounted: function(){
		this.getAllUsers();
	},
 
	methods:{
		getAllUsers: function(){
			axios.get('api.php')
				.then(function(dataRes){
					//console.log(dataRes);
					if(dataRes.data.error){
						main.msgError = dataRes.data.message;
					}
					else{
						main.users = dataRes.data.users;
					}
				});
		},
 
		saveUser: function(){
			//console.log(main.newUser);
			var memForm = main.toFormData(main.newUser);
			axios.post('api.php?crud=create', memForm)
				.then(function(dataRes){
					//console.log(dataRes);
					main.newUser = {userfname: '', userlname:''};
					if(dataRes.data.error){
						main.msgError = dataRes.data.message;
					}
					else{
						main.msgSuccess = dataRes.data.message
						main.getAllUsers();
					}
				});
		},
 
		toFormData: function(obj){
			var liveFrmDta = new FormData();
			for(var key in obj){
				liveFrmDta.append(key, obj[key]);
			}
			return liveFrmDta;
		},
 
		msgCls: function(){
			main.msgError = '';
			main.msgSuccess = '';
		}
 
	}
});

Vue.js CRUD Operations with PHP and MySQL

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 INSERT DATA INTO DATABASE USING VUEJS AND PHP 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.

Get PHP Session Value using AJAX/Jquery 0

Get PHP Session Value using AJAX/Jquery

Get PHP Session Value using AJAX/Jquery

In this Post We Will Explain About is Get PHP Session Value using AJAX/Jquery 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 how to get session value in jquery ajax Example

In this post we will show you Best way to implement Get variable from PHP file using JQuery/AJAX , hear for javascript variable value stored in php session with Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.

index.php

<?php
	session_start();
?>
<!DOCTYPE html>
<html>
<head>
	<title>How to Simple get PHP Session Value using jQuery</title>
css/bootstrap.min.css
3.1.0/jquery.min.js
3.3.7/js/bootstrap.min.js
</head>
<body>
<divclass="container">
	<h1 class="page-header text-center">How to get PHP Session Value in jQuery</h1>
	<div class="row">
		<div class="col-xl-6 col-xl-offset-3">
			<h3 class="text-center">Set simple jquery to php Session Value ( $_SESSION['value'] )</h3>
			<form method="POST" action="do_session.php">
				<input type="text" name="set_sessionVal" class="form-control" placeholder="enter simple value" required>
				<div style="margin-top:11px;">
				<button type="submit" class="live btn btn-success">Set Value</button> <a href="logout.php" type="button" class="live btn btn-danger">Remove session Value</a>
				</div>
			</form>
 
			<button type="button" id="checkSession" class="btn btn-success" style="margin-top:30px;">Check Session in jQuery</button>
		</div>
	</div>
 
	<input type="hidden" value="<?php
		if(isset($_SESSION['value'])){
			echo $_SESSION['value'];
		} 
	?>" id="session">
</div>
<script src="session.js"></script>
</body>
</html>

do_session.php

<?php
	session_start();
 
	$set_sessionVal=$_POST['set_sessionVal'];
	$_SESSION['value']=$set_sessionVal;
 
	header('location:index.php');
?>

logout.php

<?php
	session_start();
	unset($_SESSION['value']);
	header('location:index.php');
?>

session.js

$(document).ready(function(){
	//here simple conditions of check session
	$('#checkSession').click(function(){
		var session = $('#session').val();
		if(session == ''){
			alert('Live Session not Set');
			console.log('Live Session not Set');
		}
		else{
			alert('here simple Current Live Session Value: '+session);
			console.log(session);
		}
	});
});

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 Get variable from PHP file using JQuery/AJAX 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.

VueJS CRUD Operations with PHP and MySQLi Example 0

VueJS CRUD Operations with PHP and MySQLi Example

VueJS CRUD Operations with PHP and MySQLi Example

In this Post We Will Explain About is VueJS CRUD Operations with PHP and MySQLi Example 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 vue Select Insert Update Delete In Php MySQL Example

In this post we will show you Best way to implement Vue.js Update and Delete Data using PHP, hear for VueJS insert, view, edit, delete and update using PHP and Mysql with Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.

Vue.js CRUD Operation with PHP/MySQLi

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.

modal.php

<!--Pakainfo.com Edit Modal -->
<div class="myModal" v-if="usershowEditmdl">
	<div class="modalContainer">
		<div class="headerEdit">
			<span class="live headerTitle">Edit User</span>
			<button class="live editCloseBtn pull-right" @click="usershowEditmdl = false">×</button>
		</div>
		<div class="modalBody">
			<div class="live form-group">
				<label>User Firstname:</label>
				<input type="text" class="form-control" v-model="userClick.userfname">
			</div>
			<div class="live form-group">
				<label>User Lastname:</label>
				<input type="text" class="form-control" v-model="userClick.userlname">
			</div>
		</div>
		<hr>
		<div class="modalFooter">
			<div class="footerBtn pull-right">
				<button class="btn btn-default" @click="usershowEditmdl = false"><span class="glyphicon glyphicon-remove"></span> Cancel</button> <button class="btn btn-success" @click="usershowEditmdl = false; updateUser();"><span class="glyphicon glyphicon-check"></span> Save</button>
			</div>
		</div>
	</div>
</div>
 
<!-- Remove Modal -->
<div class="myModal" v-if="showDeleteModal">
	<div class="modalContainer">
		<div class="modelheaderdel">
			<span class="headerTitle">Remove User</span>
			<button class="removeCloseBtn pull-right" @click="showDeleteModal = false">×</button>
		</div>
		<div class="modalBody">
			<h5 class="text-right">You want to Remove User</h5>
			<h2 class="text-right">{{userClick.userfname}} {{userClick.userlname}}</h2>
		</div>
		<hr>
		<div class="modalFooter">
			<div class="footerBtn pull-right">
				<button class="btn btn-default" @click="showDeleteModal = false"><span class="live glyphicon glyphicon-remove"></span> Cancel</button> <button class="live btn btn-danger" @click="showDeleteModal = false; removeUser(); "><span class="live glyphicon glyphicon-trash"></span> Yes</button>
			</div>
		</div>
	</div>
</div>

style.css

.headerEdit{
	height:45px;
	font-size:20px;
	padding-left:18px;
	padding:8px;
	background: #4CAF50;
	color: #c60000;
}
 
.modelheaderdel{
	height:45px;
	font-size:20px;
	padding-left:18px;
	padding:8px;
	background: #3d3d3d;
	color: #c60000;
}
 
.editCloseBtn{
	background: #4CAF50;
	color: #c60000;
	border:none;
}
 
.removeCloseBtn{
	background: #3d3d3d;
	color: #c60000;
	border:none;
}

Updating our index.php

<!DOCTYPE html>
<html>
<head>
	<title>Vue.js Insert, update and delete Operation using PHP/MySQLi</title>
	css/bootstrap.min.css"
	<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div class="container">
	<h1 class="page-header text-right">Vue.js Insert Update Delete Operation with PHP/MySQLi</h1>
	<div id="users">
		<div class="col-md-8 col-md-offset-2">
			<div class="row">
				<div class="col-md-12">
					<h2>User List
					<button class="live btn btn-primary pull-right" @click="usershowaddmdl = true"><span class="live glyphicon glyphicon-plus"></span> User</button>
					</h2>
				</div>
			</div>
 
			<div class="live alert alert-danger text-right" v-if="msgError">
				<button type="button" class="close" @click="clsMsg();"><span aria-hidden="true">×</span></button>
				<span class="live glyphicon glyphicon-alert"></span> {{ msgError }}
			</div>
 
			<div class="live alert alert-success text-right" v-if="msgsuccess">
				<button type="button" class="close" @click="clsMsg();"><span aria-hidden="true">×</span></button>
				<span class="live glyphicon glyphicon-ok"></span> {{ msgsuccess }}
			</div>
 
			<table class="table table-bordered table-striped">
				<thead>
					<th>User Firstname</th>
					<th>User Lastname</th>
					<th>Action</th>
				</thead>
				<tbody>
					<tr v-for="user in users">
						<td>{{ user.userfname }}</td>
						<td>{{ user.userlname }}</td>
						<td>
							<button class="btn btn-success" @click="usershowEditmdl = true; selectUser(user);"><span class="glyphicon glyphicon-edit"></span> Edit</button> <button class="btn btn-danger" @click="showDeleteModal = true; selectUser(user);"><span class="glyphicon glyphicon-trash"></span> Remove</button>
 
						</td>
					</tr>
				</tbody>
			</table>
		</div>
 
		<?php include('modal.php'); ?>
	</div>
</div>
<script src="vue.js"></script>
<script src="axios.js"></script>
<script src="main.js"></script>
</body>
</html>

Adding Update and Remove Code in our API

api.php

if($crudopration == 'update'){
 
	$userid = $_POST['userid'];
	$userfname = $_POST['userfname'];
	$userlname = $_POST['userlname'];
 
	$sql = "update users set userfname='$userfname', userlname='$userlname' where userid='$userid'";
	$query = $conn->query($sql);
 
	if($query){
		$out['msg'] = "User Updated Successfully";
	}
	else{
		$out['error'] = true;
		$out['msg'] = "Could not update User";
	}
 
}
 
if($crudopration == 'delete'){
 
	$userid = $_POST['userid'];
 
	$sql = "delete from users where userid='$userid'";
	$query = $conn->query($sql);
 
	if($query){
		$out['msg'] = "User Deleted Successfully";
	}
	else{
		$out['error'] = true;
		$out['msg'] = "Could not delete User";
	}
 
}

Updating our Vue Code

main.js

var main = new Vue({
	el: '#users',
	data:{
		usershowaddmdl: false,
		usershowEditmdl: false,
		showDeleteModal: false,
		msgError: "",
		msgsuccess: "",
		users: [],
		newUser: {userfname: '', userlname: ''},
		userClick: {}
	},
 
	mounted: function(){
		this.getAllUsers();
	},
 
	methods:{
		getAllUsers: function(){
			axios.get('api.php')
				.then(function(results){
					//console.log(results);
					if(results.data.error){
						main.msgError = results.data.msg;
					}
					else{
						main.users = results.data.users;
					}
				});
		},
 
		saveUser: function(){
			//console.log(main.newUser);
			var usrForm = main.myFormData(main.newUser);
			axios.post('api.php?crudopration=create', usrForm)
				.then(function(results){
					//console.log(results);
					main.newUser = {userfname: '', userlname:''};
					if(results.data.error){
						main.msgError = results.data.msg;
					}
					else{
						main.msgsuccess = results.data.msg
						main.getAllUsers();
					}
				});
		},
 
		updateUser(){
			var usrForm = main.myFormData(main.userClick);
			axios.post('api.php?crudopration=update', usrForm)
				.then(function(results){
					//console.log(results);
					main.userClick = {};
					if(results.data.error){
						main.msgError = results.data.msg;
					}
					else{
						main.msgsuccess = results.data.msg
						main.getAllUsers();
					}
				});
		},
 
		removeUser(){
			var usrForm = main.myFormData(main.userClick);
			axios.post('api.php?crudopration=delete', usrForm)
				.then(function(results){
					//console.log(results);
					main.userClick = {};
					if(results.data.error){
						main.msgError = results.data.msg;
					}
					else{
						main.msgsuccess = results.data.msg
						main.getAllUsers();
					}
				});
		},
 
		selectUser(user){
			main.userClick = user;
		},
 
		myFormData: function(obj){
			var dataForm = new FormData();
			for(var key in obj){
				dataForm.append(key, obj[key]);
			}
			return dataForm;
		},
 
		clsMsg: function(){
			main.msgError = '';
			main.msgsuccess = '';
		}
 
	}
});

VueJS INSERT, UPDATE and DELETE

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 vue Select Insert Update Delete In Php MySQL 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.

PHP – MySQLi Insert Update Delete CRUD Operation using AngularJS 0

PHP - MySQLi Insert Update Delete CRUD Operation using AngularJS

PHP – MySQLi Insert Update Delete CRUD Operation using AngularJS

In this Post We Will Explain About is PHP – MySQLi Insert Update Delete CRUD Operation using AngularJS 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 AngularJS – Insert Update Delete using PHP and MySQL Example

In this post we will show you Best way to implement PHP – OOP CRUD Operation using Angular.js, hear for AngularJS PHP CRUD (Create, Read, Update, Delete) Operations with Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.

AngularJS CRUD Operation With PHP/MySQLi

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 `student` (
  `studentId` INT(11) NOT NULL AUTO_INCREMENT,
  `studentfname` VARCHAR(50) NOT NULL,
  `studentlname` VARCHAR(50) NOT NULL,
PRIMARY KEY(`studentId`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

Creating simple Database Connection

<?php
$db_con = new mysqli("localhost", "username", "Your_Database_Password", "livedbname");
 
if ($db_con->connect_error) {
    die("Connection failed: " . $db_con->connect_error);
}
?>

index.php

<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8"> 
<title>PHP Insert Update Delete CRUD Operation using AngularJS</title>
<link href="<a href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
</head>
<body>
<div class="container">
	<h1 class="page-header">PHP Insert Update Delete CRUD Operation using AngularJS</h1>
	<div class="row">
		<div ng-app="liveApp" ng-controller="controller" ng-init="displayData()">
			<div class="col-xl-4">
				<form ng-submit="myFunc()">
					<h3>Student Form</h3>
					<hr>
					<div class="live24u form-group">
				    	<label for="studentfname">Firstname</label>
				    	<input type="text" class="live24u form-control" id="studentfname" name="studentfname" ng-model="studentfname" placeholder="Enter Firstname">
				  	</div>
				  	<div class="live24u form-group">
				    	<label for="studentlname">Lastname</label>
				    	<input type="text" class="live24u form-control" id="studentlname" name="studentlname" ng-model="studentlname" placeholder="Enter Lastname">
				  	</div>
				  	<hr>
				  	<button type="submit" class="live24u {{buttonClass}}" ng-click="insert()"><span class="live24u {{mainico}}"></span> {{buttonName}}</button>
				</form>
			</div>
			<div class="col-xl-8">
				<h3>Student List</h3>
				<table class="live table table-bordered dbn table-striped">
					<thead>
						<th>student Firstname</th>
						<th>student Lastname</th>
						<th>Action</th>
					</thead>
					<tbody>
						<tr ng-repeat="stud in student">
							<input type="hidden" value="{{stud.studentId}}">
							<td>{{stud.studentfname}}</td>
							<td>{{stud.studentlname}}</td>
							<td>
								<button class="live btn btn-success" ng-click="update(stud.studentId, stud.studentfname, stud.studentlname)"><span class="live glyphicon glyphicon-pencil"></span> Edit</button> || <button class="live btn btn-danger" ng-click="delete(stud.studentId)"><span class="live glyphicon glyphicon-trash"></span> Delete</button>
							</td>
						</tr>
					</tbody>
				</table>
			</div>
		</div>
	</div>
</div>
<script src="main.js"></script>
</body>
</html>

main.js

var app = angular.module("liveApp", []);
app.controller("controller", function($scope, $http) {
    $scope.buttonName = "Save";
    $scope.mainico = "glyphicon glyphicon-floppy-disk";
    $scope.buttonClass = "btn btn-success";
    $scope.insert = function() {
        if ($scope.studentfname == null) {
            alert("Please input Student Firstname");
        } 
        else if ($scope.studentlname == null) {
            alert("Please input Student Lastname");
        }  
        else {
            $http.post(
                "action.php", {
                    'studentfname': $scope.studentfname,
                    'studentlname': $scope.studentlname,
                    'buttonName': $scope.buttonName,
                    'studentId': $scope.studentId,
                }
            ).success(function(data) {
                alert(data);
                $scope.studentfname = null;
                $scope.studentlname = null;
                $scope.buttonName = "Save";
                $scope.mainico = "glyphicon glyphicon-floppy-disk";
                $scope.buttonClass = "btn btn-success";
                $scope.displayData();
            });
        }
    }
    $scope.displayData = function() {
        $http.get("fetch.php")
            .success(function(data) {
                $scope.student = data;
            });
    }
    $scope.update = function(studentId, studentfname, studentlname) {
        $scope.studentId = studentId;
        $scope.studentfname = studentfname;
        $scope.studentlname = studentlname;
        $scope.mainico = "glyphicon glyphicon-check";
        $scope.buttonClass = "btn btn-success";
        $scope.buttonName = "Update";
    }
    $scope.delete= function(studentId) {
        if (confirm("you want to really delete student?")) {
            $http.post("delete.php", {
                    'studentId': studentId
                })
                .success(function(data) {
                    alert(data);
                    $scope.displayData();
                });
        } else {
            return false;
        }
    }
});

fetch.php

<?php
	include('db_con.php');
	$result = array();
	$query = $db_con->query("select * from student"); 
	if ($query->num_rows > 0) {
	    while ($datarow = $query->fetch_array()) {
	        $result[] = $datarow;
	    }
	    echo json_encode($result);
	}
?>

action.php

<?php
    include('db_con.php');
    $get_data = json_decode(file_get_contents("php://input"));
    if (count($get_data) > 0) {
        $studentfname = mysqli_real_escape_string($db_con, $get_data->studentfname);
        $studentlname = mysqli_real_escape_string($db_con, $get_data->studentlname);
        $actBtnName = $get_data->buttonName;
        if ($actBtnName == "Save") {
            if ($db_con->query("insert into student (studentfname, studentlname) values ('$studentfname', '$studentlname')")) {
                echo "Student Added Successfully";
            } else {
                echo 'Failed';
            }
        }
        if ($actBtnName == "Update") {
            $id    = $get_data->studentId;
            if ($db_con->query("update student set studentfname='$studentfname', studentlname='$studentlname' where studentId='$id'")) {
                echo 'Student Updated Successfully';
            } else {
                echo 'Sorry Failed';
            }
        }
    }
?>

delete.php

<?php
	include('db_con.php');
	$data = json_decode(file_get_contents("php://input"));
	if (count($data) > 0) {
	    $id = $data->studentId;
	    if ($db_con->query("delete from student where studentId='$id'")) {
	        echo 'Student Deleted Successfully';
	    } else {
	        echo 'Failed';
	    }
	}
?>

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 AngularJS CRUD Operations with PHP and MySQL 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.

Create Dynamic Image Fancybox Gallery with jQuery, PHP & MySQL 0

Create Dynamic Image Fancybox Gallery with jQuery, PHP & MySQL

Create Dynamic Image Fancybox Gallery with jQuery, PHP & MySQL

In this Post We Will Explain About is Create Dynamic Image Fancybox Gallery with jQuery, PHP & 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 Responsive Photo Gallery with jQuery Example

In this post we will show you Best way to implement Creating dynamic Photo Gallery with jQuery, PHP & MySQL, hear for How to Create Dynamic Image Gallery with jQuery, PHP & MySQL with Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.

Creating simple Database

CREATE TABLE `Gallery_photo` (
  `liveImgId` INT(11) NOT NULL AUTO_INCREMENT,
  `information` text NOT NULL,
  `img_location` VARCHAR(150) NOT NULL,
PRIMARY KEY(`liveImgId`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

Include External Libs

<link rel="stylesheet" href="css/bootstrap.min.css" rel="nofollow">
<script src="jquery/3.1.0/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<link rel="stylesheet" type="text/css" href="fancybox/jquery.fancybox.css">
<script src="//code.jquery.com/jquery-3.1.1.min.js"></script>
<script src="fancybox/jquery.fancybox.js"></script>

index.php

<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8" />
	<title>jquery PHP Gallery using Fancybox Example</title>
	<script type="text/javascript">
	    $("[data-fancybox]").fancybox({ });
	</script>
</head>
<body>
	<div class="container">
		<h1 class="page-header text-center">Fancybox - Fancy jQuery lightbox alternative</h1>
		<h2>
			Photo List
			<a href="#liveaddImg" data-toggle="modal" class="pull-right btn btn-success"><span class="live24u glyphicon glyphicon-plus"></span> Photo</a>
		</h2>
		<?php
			session_start();
 
			if(isset($_SESSION['success'])){
				?>
				<div class="alert alert-success text-center">
					<?php echo $_SESSION['success']; ?>
				</div>
				<?php
 
				unset($_SESSION['success']);
			}
 
			if(isset($_SESSION['galleryError'])){
				?>
				<div class="alert alert-danger text-center">
					<?php echo $_SESSION['galleryError']; ?>
				</div>
				<?php
 
				unset($_SESSION['galleryError']);
			}
		?>
		<table class="table">
			<thead>
				<th>Information</th>
				<th>Gallery Location</th>
				<th>Gallery</th>
			</thead>
			<tbody>
				<?php
					$db_con = new mysqli("localhost", "username", "password", "gallery");
 
					if ($db_con->connect_error) {
					    die("Connection failed: " . $db_con->connect_error);
					}
 
					$sql="select * from Gallery_photo";
					$query=$db_con->query($sql);
					while($datarow=$query->fetch_array()){
						?>
						<tr>
							<td><?php echo $datarow['information']; ?></td>
							<td><?php echo $datarow['img_location']; ?></td>
							<td><a href="<?php echo $datarow['img_location']; ?>" data-fancybox="group" data-caption="<?php echo $datarow["information"]; ?>"><img src="<?php echo $datarow['img_location']; ?>" height="30px" width="30px"></a></td>
						</tr>
						<?php
					}
				?>
			</tbody>
		</table>
	</div>
 
	<!--create / Add Photo -->
	<div class="modal fade" id="liveaddImg" tabindex="-1" role="dialog" aria-labelledby="live_createModel">
		<div class="modal-dialog" role="document">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
					<h4 class="live modal-title text-center" id="live_createModel">Add New Photo</h4>
				</div>
				<div class="live modal-body">
					<div class="live24u container-fluid">
					<form method="POST" action="do_upload.php" enctype="multipart/form-data">
				    	<div class="form-group">
							<div class="row">
					    		<div class="col-xl-2" style="margin-top:8px;">
					    			<label>Description:</label>
					    		</div>
					    		<div class="col-xl-10">
					    			<input type="text" class="form-control" name="information" required>
					    		</div>
					    	</div>
				    	</div>
				    	<div class="live form-group">
				    		<div class="row">
					    		<div class="col-xl-2" >
					    			<label>Gallery Photo:</label>
					    		</div>
					    		<div class="col-xl-10">
					    			<input type="file" name="image">
					    		</div>
					    	</div>
				    	</div>
				    </div>
				</div>
				<div class="live modal-footer">
					<button type="button" class="live24u btn btn-default" data-dismiss="modal"><span class="live glyphicon glyphicon-remove"></span> Cancel</button>
					<button type="submit" class="btn btn-success"><span class="live24u glyphicon glyphicon-floppy-disk"></span> Save</button>
					</form>
				</div>
			</div>
		</div>
	</div>
 
</body>
</html>

do_upload.php

<?php
	session_start();
 
	$db_con = new mysqli("localhost", "username", "yourpassword", "gallery");
	if ($db_con->connect_error) {
	    die("Connection failed: " . $db_con->connect_error);
	}
 
	$information=$_POST['information'];
 
	$getDataInfo = PATHINFO($_FILES["image"]["name"]);
	if (empty($_FILES["image"]["name"])){
		$_SESSION['galleryError']="Upload Failed. Sorry File empty!";
		header('img_location:index.php');
	}
	else{
		if ($getDataInfo['extension'] == "jpg" OR $getDataInfo['extension'] == "jpeg" OR $getDataInfo['extension'] == "png") {
			$newdataFile = $getDataInfo['filename'] . "_" . time() . "." . $getDataInfo['extension'];
			move_uploaded_file($_FILES["image"]["tmp_name"], "upload/" . $newdataFile);
			$img_location = "upload/" . $newdataFile;
 
			$sql="insert into Gallery_photo (information, img_location) values ('$information', '$img_location')";
			$query=$db_con->query($sql);
 
			if($query){
				$_SESSION['success']="Gallery Photo uploaded Successfully Good Lick!";
			}
			else{
				$_SESSION['galleryError']="Something went wrong. Please check to Can't upload Photo!";
			}
 
			header('img_location:index.php');
 
		}
		else{
			$_SESSION['galleryError']="Upload Failed. Sorry Please check upload any format JPG or PNG Gallery_photo only!";
			header('img_location:index.php');
		}
	}
 
?>

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 Fancybox – Fancy jQuery lightbox alternative 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.

How to write SQL Sub Query in PHP with MySQLi 0

How to write SQL Sub Query in PHP with MySQLi

How to write SQL Sub Query in PHP with MySQLi

In this Post We Will Explain About is How to write SQL Sub Query in PHP with MySQLi 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 SQL subquery with multiple results Example

In this post we will show you Best way to implement SQL Sub Query in PHP/MySQLi, hear for How to write subquery in FROM clause with Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.

Creating Simple Database

CREATE TABLE `students` (
  `studenid` INT(11) NOT NULL AUTO_INCREMENT,
  `studentId` INT(11) NOT NULL,
  `student_post` VARCHAR(200) NOT NULL,
  `studregDate` datetime NOT NULL,
PRIMARY KEY(`studenid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

INSERT INTO `students` (`studenid`, `studentId`, `student_post`, `studregDate`) VALUES
(1, 1, 'jaydeep Gondaliya', '2018-09-13 08:00:00'),
(2, 1, 'Ankit kathiriya', '2018-10-19 13:30:00'),
(3, 1, 'krunal sisodiya', '2018-10-04 20:05:00'),
(4, 1, 'mayur dhameliya', '2018-10-02 15:10:00'),
(5, 1, 'hitesh dhameliya', '2018-10-15 07:40:00'),
(6, 1, 'chirag dethariya', '2018-09-20 23:00:00'),
(7, 1, 'vivek viradiya', '2018-10-04 01:00:00'),
(8, 1, '#vishal pandya', '2018-09-01 22:05:00');

Creating Simple Connection

<?php
 
$db_con = mysqli_connect("localhost","username","password","crudopet");
if (!$db_con) {
	die("Connection failed: " . mysqli_connect_error());
}
 
?>

Example 1 : table students order by studregDate asc

<?php
	$asc=mysqli_query($db_con,"select * from students order by studregDate asc");
	while($rowasc=mysqli_fetch_array($asc)){
		?>
		<tr>
			<td><?php echo $rowasc['studenid']; ?></td>
			<td><?php echo $rowasc['student_post']; ?></td>
			<td><?php echo date('M-d, Y h:i A',strtotime($rowasc['studregDate'])); ?></td>
		</tr>
		<?php
	}
?>

Example 2 : table students order by studregDate desc

<?php
	$desc=mysqli_query($db_con,"select * from students order by studregDate desc");
	while($rowdesc=mysqli_fetch_array($desc)){
		?>
		<tr>
			<td><?php echo $rowdesc['studenid']; ?></td>
			<td><?php echo $rowdesc['student_post']; ?></td>
			<td><?php echo date('M-d, Y h:i A',strtotime($rowdesc['studregDate'])); ?></td>
		</tr>
		<?php
	}
?>

Example 3 : table students order by studregDate desc limit 3

<?php
	$limit=mysqli_query($db_con,"select * from students order by studregDate desc limit 3");
	while($rowlimit=mysqli_fetch_array($limit)){
		?>
		<tr>
			<td><?php echo $rowlimit['studenid']; ?></td>
			<td><?php echo $rowlimit['student_post']; ?></td>
			<td><?php echo date('M-d, Y h:i A',strtotime($rowlimit['studregDate'])); ?></td>
		</tr>
		<?php
	}
?>

Subquery

<?php
	$sub=mysqli_query($db_con,"select * from (select * from students order by studregDate desc limit 3)as sub left join student on student.studentId=sub.studentId order by studregDate asc");
	while($low_subRow=mysqli_fetch_array($sub)){
		?>
		<tr>
			<td><?php echo $low_subRow['studenid']; ?></td>
			<td><?php echo $low_subRow['studentFname']; ?> <?php echo $low_subRow['studlname']; ?></td>
			<td><?php echo $low_subRow['student_post']; ?></td>
			<td><?php echo date('M-d, Y h:i A',strtotime($low_subRow['studregDate'])); ?></td>
		</tr>
		<?php
	}
?>

index.php

<?php include('db_con.php'); ?>
<!DOCTYPE>
<html>
<head>
<title>Simple SQL SubQuery using PHP with MySQLi</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"" rel="nofollow">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
	<div class="row">
		<h2><center>Simple SQL SubQuery in PHP as well as MySQLi</center></h2>
	</div>
	<div class="row">
		<span>order by studregDate asc</span>
		<table class="table table-bordered">
			<thead>
				<th>StudentID</th>
				<th>Stud Text</th>
				<th>Stud Reg Date</th>
			</thead>
			<tbody>
				<?php
					$asc=mysqli_query($db_con,"select * from students order by studregDate asc");
					while($rowasc=mysqli_fetch_array($asc)){
						?>
						<tr>
							<td><?php echo $rowasc['studenid']; ?></td>
							<td><?php echo $rowasc['student_post']; ?></td>
							<td><?php echo date('M-d, Y h:i A',strtotime($rowasc['studregDate'])); ?></td>
						</tr>
						<?php
					}
				?>
			</tbody>
		</table>
	</div>
	<div class="row">
		<span>order by studregDate desc</span>
		<table class="table table-bordered">
			<thead>
				<th>StudentID</th>
				<th>Stud Text</th>
				<th>Stud Reg Date</th>
			</thead>
			<tbody>
				<?php
					$desc=mysqli_query($db_con,"select * from students order by studregDate desc");
					while($rowdesc=mysqli_fetch_array($desc)){
						?>
						<tr>
							<td><?php echo $rowdesc['studenid']; ?></td>
							<td><?php echo $rowdesc['student_post']; ?></td>
							<td><?php echo date('M-d, Y h:i A',strtotime($rowdesc['studregDate'])); ?></td>
						</tr>
						<?php
					}
				?>
			</tbody>
		</table>
	</div>
	<div class="row">
		<span>Simple order by studregDate desc limit 3</span>
		<table class="table table-bordered>
			<thead>
				<th>StudentID</th>
				<th>Stud Text</th>
				<th>Stud Date</th>
			</thead>
			<tbody>
				<?php
					$limit=mysqli_query($db_con,"select * from students order by studregDate desc limit 3");
					while($rowlimit=mysqli_fetch_array($limit)){
						?>
						<tr>
							<td><?php echo $rowlimit['studenid']; ?></td>
							<td><?php echo $rowlimit['student_post']; ?></td>
							<td><?php echo date('M-d, Y h:i A',strtotime($rowlimit['studregDate'])); ?></td>
						</tr>
						<?php
					}
				?>
			</tbody>
		</table>
	</div>
	<div class="row">
		<span>(order by studregDate desc limit 3) as subquery order by studregDate asc</span>
		<table class="table">
			<thead>
				<th>StudentID</th>
				<th>student</th>
				<th>Stud Text</th>
				<th>Stud Date</th>
			</thead>
			<tbody>
				<?php
					$sub=mysqli_query($db_con,"select * from (select * from students order by studregDate desc limit 3)as sub left join student on student.studentId=sub.studentId order by studregDate asc");
					while($low_subRow=mysqli_fetch_array($sub)){
						?>
						<tr>
							<td><?php echo $low_subRow['studenid']; ?></td>
							<td><?php echo $low_subRow['studentFname']; ?> <?php echo $low_subRow['studlname']; ?></td>
							<td><?php echo $low_subRow['student_post']; ?></td>
							<td><?php echo date('M-d, Y h:i A',strtotime($low_subRow['studregDate'])); ?></td>
						</tr>
						<?php
					}
				?>
			</tbody>
		</table>
	</div>
</div>
</body>
</html>

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 MySQL WHERE Clause with Examples – AND, OR, IN, NOT IN 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.

Convert Array to XML and XML to Array using PHP 0

Convert Array to XML and XML to Array using PHP

Convert Array to XML and XML to Array using PHP

In this Post We Will Explain About is Convert Array to XML and XML to Array using PHP 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 Convert PHP associative array to XML Example

In this post we will show you Best way to implement How To Convert XML To Associative Array in PHP, hear for Array to Xml Conversion and Xml to Array Convert in PHP with Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.

Parsing XMLdata and converting in array using PHP

The makeDataXML() methods converts simple example of the PHP multidimensional array to XML data file. and then The All the data array needs to be simple all the data passed as a parameter in makeDataXML() methods. The makeDataXML() methods make an XML data document using PHO DOMDocument class and insert the simple PHP array data content in this XML data document. At the simple end, the data XML document(DOM) is saved data as an Data XML file using PHP in the specified root file path.

Convert simple PHP Multidimensional Array to XML data File

makeDataXML() methods:

function makeDataXML($data) {
    $title = $data['title'];
    $rowCount = count($data['students']);
    
    //create the xml document
    $xmlDoc = new DOMDocument();
    
    $root = $xmlDoc->appendChild($xmlDoc->createElement("student_info"));
    $root->appendChild($xmlDoc->createElement("title",$title));
    $root->appendChild($xmlDoc->createElement("totalRows",$rowCount));
    $tabUsers = $root->appendChild($xmlDoc->createElement('rows'));
    
    foreach($data['students'] as $student){
        if(!empty($student)){
            $tabUser = $tabUsers->appendChild($xmlDoc->createElement('student'));
            foreach($student as $key=>$val){
                $tabUser->appendChild($xmlDoc->createElement($key, $val));
            }
        }
    }
    
    header("Content-Type: text/plain");
    
    //make the output pretty
    $xmlDoc->formatOutput = true;
    
    //save xml file
    $file_name = str_replace(' ', '_',$title).'_'.time().'.xml';
    $xmlDoc->save("files/" . $file_name);
    
    //return xml file name
    return $file_name;
}

PHP Example of the Multidimensional Array

$data = array(
    'title' => 'Students Information',
    'students' => array(
        array('name' => 'jaydeep Gondaliya', 'email' => '[email protected]'),
        array('name' => 'mayur dhameliya', 'email' => '[email protected]'),
        array('name' => 'Hitesh Dhameliya', 'email' => '[email protected]')
    )
);

PHP simple Array to XML File convert

echo makeDataXML($data);

The example code will create the following XML document.

<?xml version="1.0"?>
<student_info>
  <title>Students Information</title>
  <totalRows>3</totalRows>
  <rows>
    <student>
      <name>jaydeep Gondaliya</name>
      <email>[email protected]</email>
    </student>
    <student>
      <name>mayur dhameliya</name>
      <email>[email protected]</email>
    </student>
    <student>
      <name>Hitesh Dhameliya</name>
      <email>[email protected]</email>
    </student>
  </rows>
</student_info>

Convert XML to PHP Associative Array

//here simple xml file path using php
$datapath = "files/path-to-document.xml";

//read data simple entire file into string using file_get_contents
$xml_getfile = file_get_contents($datapath);

//convert simple Data xml data string into an object
$data_xml = simplexml_load_string($xml_getfile);

//convert data simple into json
$json  = json_encode($data_xml);

//convert data into associative array using PHP
$xmlArr = json_decode($json, true);

print_r($xmlArr);

Output

The best example source code will simple convert the XML file using PHP to the following simple source code to associative array in php.

Array
(
    [title] => Students Information
    [totalRows] => 3
    [rows] => Array
        (
            [student] => Array
                (
                    [0] => Array
                        (
                            [name] => jaydeep Gondaliya
                            [email] => [email protected]
                        )

                    [1] => Array
                        (
                            [name] => mayur dhameliya
                            [email] => [email protected]
                        )

                    [2] => Array
                        (
                            [name] => Hitesh Dhameliya
                            [email] => [email protected]
                        )

                )

        )

)

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 php – How to convert array to SimpleXML 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.

Multiple Database Connections using Laravel 0

Multiple Database Connections using Laravel

Multiple Database Connections using Laravel

In this Post We Will Explain About is Multiple Database Connections using Laravel 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 connect multiple database in laravel Example

In this post we will show you Best way to implement How to connect multiple database in laravel 5.5, hear for laravel use multiple database with Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.

Step 1 : Install Laravel

In some multiple protect we need to use database connect to multiple databases for same web-application. Lets Display how to use step by step multiple database using laravel 5.5 First of allInstall We laravel Web-application as well as simple connect with primary main database

Step 2 : MAke a database in Mysql

Make simple second database in We use own phpmyadmin

Step 3 : config/database.php

Generally simple provide We database connection Information in We config/database.php

Like as a …

'mysql' => [
            'driver' => 'mysql',
            'host' => env('DB_HOST', 'localhost'), //host
            'port' => env('DB_PORT', '3306'),//port
            'database' => env('DB_DATABASE', 'forge'),//dbname
            'username' => env('DB_USERNAME', 'forge'),//username
            'password' => env('DB_PASSWORD', ''),//password
            'unix_socket' => env('DB_SOCKET', ''),//socket
            'charset' => 'utf8',
            'collation' => 'utf8_unicode_ci',
            'prefix' => '',
            'strict' => true,
            'engine' => null,
        ],

        'mysql2' => [
            'driver' => 'mysql',
            'host' => 'localhost', //hostname
            'port' => '3306',		//port
            'database' => 'multiple',//databasename
            'username' => 'root', //username
            'password' => 'root', //password
            'unix_socket' => '',
            'charset' => 'utf8',
            'collation' => 'utf8_unicode_ci',
            'prefix' => '',
            'strict' => true,
            'engine' => null,
        ],

Step 4 :

Use We database connection in Schema to Make table for We new tables for new database

//laravel simple create migrate up methods
public function up()
    {
        Schema::connection('mysql2')->create('roles', function (Blueprint $table) {
            $table->increments('id');
            $table->string('role')->nullable();
            $table->string('capabilities')->nullable();
            $table->timestamps();
        });
    }

    /**
     * Reverse simple laravel the migrations.
     *data type
     * @return void
     */
	 //laravel simple create migrate Down methods
    public function down()
    {
        Schema::dropIfExists('roles');
    }

Step 5 : run Project

Run We need to browser laravel migration to Make table

php artisan migrate --database="YourDatabaseConnName"

Step 6 : database Connection

All the Product We model with connection

<?php
//import namespace
namespace App;
//model use
use Illuminate\Database\Eloquent\Model;

//simple extends class
class Role extends Model
{
   protected $connection = 'mysql2';
    /**
     * The all laravel attributes that are some mass assignable.
     *
     * @var simple php array
     */
    protected $fillable = [
        'role',
        'capabilities'
    ];
}

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 How to connect multiple database in laravel 5.5 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.