Vue.js GET ajax request Fetch Data using PHP
In this Post We Will Explain About is Vue.js GET ajax request Fetch Data 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 Vue.js GET ajax request with PHP (Fetching data) Example
In this post we will show you Best way to implement Vue.js Get JSON Data From MYSQL Database Using PHP, hear for how to retrieve data from mysql database in Vue.js with Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.
Creating our Database
CREATE TABLE `students` ( `studid` INT(11) NOT NULL AUTO_INCREMENT, `studentfname` VARCHAR(30) NOT NULL, `studentlname` VARCHAR(30) NOT NULL, PRIMARY KEY(`studid`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
Inserting student Data into our Database
INSERT INTO `students` (`studid`, `studentfname`, `studentlname`) VALUES (1, 'jaydeep', 'Gondaliya'), (2, 'krunal', 'sisodiya');
Include External Libs
https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css
index.php
Example of the Vue.js CRUD OPERATION with PHP and MySQLi
Student List
Student Firstname Student Lastname Action {{ stud.studentfname }} {{ stud.studentlname }}
api.php
connect_error) { die("Connection failed: " . $conn->connect_error); } $out = array('error' => false); $crud = 'read'; if(isset($_GET['crud'])){ $crud = $_GET['crud']; } if($crud = 'read'){ $sql = "select * from students"; $query = $conn->query($sql); $students = array(); while($row = $query->fetch_array()){ array_push($students, $row); } $out['students'] = $students; } $conn->close(); header("Content-type: application/json"); echo json_encode($out); die(); ?>
main.js
var main = new Vue({ el: '#students', data:{ students: [] }, mounted: function(){ this.getAllStudents(); }, methods:{ getAllStudents: function(){ axios.get("api.php") .then(function(response){ //console.log(response); main.students = response.data.students; }); } } });
You are Most welcome in my youtube Channel Please subscribe my channel. and give me FeedBack.
More Details……
Angularjs Example
I hope you have Got What is How to get data from MySQL with Vue.js – 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.