A program that I wrote using PHP as my server language, MySQL as my backend database and JQuery for my frontend to retrieve all the records in the database.
I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me in the following email address for further details. If you want to advertise on my website kindly contact me also in my email address also. Thank you.
My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.
My mobile number here in the Philippines is 09173084360.
My telephone number at home here in Bacolod City, Negros Occidental Philippines is +63 (034) 4335675.
Here in Bacolod I also accepting computer repair, networking and Arduino Project development at a very affordable price.
My personal website is http://www.jakerpomperada.com
Sample Program Output
Program Listing
index.php
<html>
<head>
<title>Display All The Record From MySQL Using JQuery</title>
<link rel="stylesheet" href="bootstrap.min.css" />
<script src="jquery-3.4.0.min.js"></script>
</head>
<body>
<div class="container">
<br />
<h3 align="center">Display All The Records From MySQL Using JQuery</a></h3><br />
<br />
<div class="table-responsive" id="show_records">
</div>
</div>
<script type="text/javascript">
/* Written By Mr. Jake R. Pomperada,MAED-IT
April 30, 2019 Tuesday
Bacolod City, Negros Occidental */
load_data();
function load_data()
{
$.ajax({
url:"fetch.php",
method:"POST",
success:function(data)
{
$('#show_records').html(data);
}
});
}
</script>
</body>
</html>
fetch.php
<?php
//fetch.php
/* Written By Mr. Jake R. Pomperada,MAED-IT
April 30, 2019 Tuesday
Bacolod City, Negros Occidental */
include("database_connection.php");
$query = "SELECT * FROM tbl_students";
$statement = $connect->prepare($query);
$statement->execute();
$result = $statement->fetchAll();
$total_row = $statement->rowCount();
$output = '
<table class="table table-striped table-bordered">
<tr>
<th>First Name</th>
<th>Last Name</th>
<th>Course</th>
</tr>
';
if($total_row > 0)
{
foreach($result as $row)
{
$output .= '
<tr>
<td width="10%">'.$row["first_name"].'</td>
<td width="10%">'.$row["last_name"].'</td>
<td width="15%">'.$row["course"].'</td>
</tr>
';
}
}
else
{
$output .= '
<tr>
<td colspan="5" align="center">Data not found</td>
</tr>
';
}
$output .= '</table>';
echo $output;
?>
tbl_students.sql
-- phpMyAdmin SQL Dump
-- version 4.8.5
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Apr 30, 2019 at 08:49 AM
-- Server version: 10.1.38-MariaDB
-- PHP Version: 7.1.28
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET AUTOCOMMIT = 0;
START TRANSACTION;
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Database: `students`
--
-- --------------------------------------------------------
--
-- Table structure for table `tbl_students`
--
CREATE TABLE `tbl_students` (
`id` int(11) NOT NULL,
`first_name` varchar(200) NOT NULL,
`last_name` varchar(200) NOT NULL,
`course` varchar(300) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `tbl_students`
--
INSERT INTO `tbl_students` (`id`, `first_name`, `last_name`, `course`) VALUES
(3, 'Jake', 'Pomperada', 'Bachelor of Science in Computer Science'),
(4, 'Ma. Junallie', 'Pomperada', 'Bachelor of Science in Chemical Engineering'),
(5, 'Jacob Samuel', 'Pomperada', 'Bachelor of Science in Business Management'),
(6, 'Julianna Rae', 'Pomperada', 'Bachelor of Science in Accountancy'),
(7, 'Lydia', 'Pomperada', 'Bachelor of Science in Social Studies'),
(8, 'Virgilio', 'Pomperada', 'Bachelor of Science in Agriculture'),
(9, 'Leslie Vinky', 'Pomperada', 'Bachelor of Science in Electronics Engineering'),
(11, 'Kobe', 'Bryant', 'Master in Information Technology');
--
-- Indexes for dumped tables
--
--
-- Indexes for table `tbl_students`
--
ALTER TABLE `tbl_students`
ADD PRIMARY KEY (`id`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `tbl_students`
--
ALTER TABLE `tbl_students`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=12;
COMMIT;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
No comments:
Post a Comment