Skip to content

Commit 7bc9ced

Browse files
authored
Create getAllTests.php
1 parent cd82e5c commit 7bc9ced

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

BACKEND/getAllTests.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
require_once "config.php";
4+
5+
//open connection to mysql db
6+
//$connection = mysqli_connect($host,$user,$pass,$db) or die("Error " . mysqli_error($connection));
7+
8+
//fetch table rows from mysql db
9+
$sql = "SELECT TestID, TestDesc, UserID As CreatedByID, CONCAT_WS(' ', FirstName, LastName) AS CreatedByName, DateCreated FROM TblTest Inner Join TblUser ON TblTest.CreatedBy = TblUser.UserID";
10+
11+
$result = mysqli_query($connection, $sql) or die("Error in Selecting Tests " . mysqli_error($connection));
12+
13+
// Convert MySQL Result Set to PHP Array
14+
// Create an array
15+
$empArray = array();
16+
while($row =mysqli_fetch_assoc($result))
17+
{
18+
$empArray[] = $row;
19+
}
20+
21+
//Convert PHP Array to JSON String
22+
echo json_encode($empArray);
23+
24+
//close the db connection
25+
mysqli_close($connection);
26+
?>

0 commit comments

Comments
 (0)