Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
Showing results for 
Search instead for 
Did you mean: 
Hello Readers,

Here I am going to show how to connect an SAPUI5 application to a MySQL database using PHP.


Prerequisites -

  • Install WAMP server / XAMPP server.

  • Install PHP.Usually comes in built with the server.

Step 1 - Create a database and a table,Insert content.

In my case I am using PHPMyAdmin to create a database (Employee).In it I am creating a table (user) and within it I am inserting some records.

Step 2- Create a SAPUI5 application.

Here,I am creating an SAPUI5 application,wherein I am creating an empty JSON model and calling an ajax function with source to my php file.On the success function,to the JSON model,I set the data recieved from my PHP file.

Afterwards I am showing the data in a table(ui.table.Table), by setting the JSON model.

As this is an basic program,all the code is implemented in the index.html file itself.

My index.html file goes like this :-
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta http-equiv='Content-Type' content='text/html;charset=UTF-8'/>

<script src=""
<!-- only load the mobile lib "sap.m" and the "sap_bluecrystal" theme -->


var json = new sap.ui.model.json.JSONModel();
url: 'tableData.php',
success: function(data) //on recieve of reply
error: function(err)

var tableo = new sap.ui.table.Table({
title : "Arjun's First Table",
visibleRowCount : 5
tableo.addColumn(new sap.ui.table.Column({
label : new sap.ui.commons.Label({text:"Userid"}),
template : new sap.ui.commons.TextField().bindProperty("value","Userid"),
width : "140px"
tableo.addColumn(new sap.ui.table.Column({
label : new sap.ui.commons.Label({text:"Name"}),
template : new sap.ui.commons.TextField().bindProperty("value","Name"),
width : "140px"
tableo.addColumn(new sap.ui.table.Column({
label : new sap.ui.commons.Label({text:"Age"}),
template : new sap.ui.commons.TextField().bindProperty("value","Age"),
width : "140px"
tableo.addColumn(new sap.ui.table.Column({
label : new sap.ui.commons.Label({text:"Email"}),
template : new sap.ui.commons.TextField().bindProperty("value","Email"),
width : "140px"



<body class="sapUiBody" role="application">
<div id="content"></div>

Step 3-  Write the PHP file


In my PHP file tableData.php, I am writing a query to the database and sending the data to front end in JSON format.


$servername = "localhost";
$username = "root";
$password = "";
$dbname = "employee";

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);

$sql = "select * from user";

$res = mysqli_query($conn,$sql);

$result = array();

while($row = mysqli_fetch_array($res)){

echo json_encode(array('result'=>$result));

Step 4 - Now execute the index.html -


Thus, we have successfully displayed MySQL table data into an SAPUI5 table.
Labels in this area