Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $servername = "yourServerName.com";
- $username = "yourUserName";
- $password = "yourPassword";
- $dbname = "yourDatabaseName";
- $conn = new mysqli($servername, $username, $password, $dbname);
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- $size = array(4,2,1);
- $sql = "SELECT userName, userContact FROM Persons";
- $result = $conn->query($sql);
- $response = array(
- "c2array" => true,
- "size" => $size,
- "data" => array()
- );
- while ( $row = $result->fetch_assoc() ) {
- $response['data'][] = array(
- array($row['userName']),
- array($row['userContact'])
- );
- }
- echo json_encode($response);
- $conn->close();
- exit();
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement