Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //nawiązywanie połączenia
- require_once "connect.php";
- mysqli_report(MYSQLI_REPORT_STRICT);
- try
- {
- $polaczenie = new mysqli($host, $db_user, $db_password, $db_name);
- if ($polaczenie->connect_errno!=0)
- {
- throw new Exception(mysqli_connect_errno());
- }
- else
- {
- header('Content-Type: application/json; charset=utf8');
- //fetch table rows from mysql db
- $sql = "select * from tbl_employee";
- $result = mysqli_query($polaczenie, $sql) or die("Error in Selecting " . mysqli_error($polaczenie));
- //create an array
- $emparray = array();
- while($row =mysqli_fetch_assoc($result))
- {
- $emparray[] = $row;
- }
- echo json_encode($emparray);
- $polaczenie->close();
- }
- }
- catch(Exception $e)
- {
- echo '<span style= "color:red;">Błąd serwera!</span>';
- echo '<br/> Informacja developerska: '.$e;
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement