-
Notifications
You must be signed in to change notification settings - Fork 0
/
jsonp_demo_db.php
52 lines (35 loc) · 1.08 KB
/
jsonp_demo_db.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
header("Content-Type: application/json; charset=UTF-8");
$obj = json_decode($_GET["x"], false);
//this is my laptop server username and password.If you want you can change those things to your code
$servername = "127.0.0.1";
$username = "root";
$password = "";
$dbname = "banana";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT * FROM newquestions ";
$result = $conn->query($sql);
$outp = array();
$outp = $result->fetch_all(MYSQLI_ASSOC);
echo "myFunc(".json_encode($outp).")";
// codes bellow I used for testing when implimenting when you implimenting new system you can use for your tsting
/*for ($x=0;$x<count($outp);$x++)
{
echo json_encode($outp[$x]);
echo "</br>";
}*/
/*if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
echo "Event :" . $row["Event"]. " Location : ".$row["Location"]. "<br>";
}
} else {
echo "0 results";
}*/
$conn->close();
?>