PHP Classes

File: fwphp/glomodul/z_examples/AJAX_form_valid/data_transfer_to_mysql/json.php

Recommend this page to a friend!
  Classes of Slavko Srakocic   B12 PHP FW   fwphp/glomodul/z_examples/AJAX_form_valid/data_transfer_to_mysql/json.php   Download  
File: fwphp/glomodul/z_examples/AJAX_form_valid/data_transfer_to_mysql/json.php
Role: Auxiliary script
Content type: text/plain
Description: Auxiliary script
Class: B12 PHP FW
Manage database records with a PDO CRUD interface
Author: By
Last change: Update of fwphp/glomodul/z_examples/AJAX_form_valid/data_transfer_to_mysql/json.php
Date: 1 year ago
Size: 556 bytes
 

Contents

Class file image Download
<?php
include('conn.php');

$sql = "select * from users";
$result = mysqli_query($conn, $sql) or die ("error" . mysqli_error($conn));
$myArray = array();
while(
$row = mysqli_fetch_assoc($result)){
   
$myArray[] = $row;
}
mysqli_close($conn);



header('Content-Type: application/json');
//$json = file_get_contents('json.json');
/*
$myArray = array("user1" => array("firstName" => "Mike2", "lastName" => "Smith" , "age" => 34),"user2" => array("firstName" => "Mike2", "lastName" => "Smith" , "age" => 34));
*/
$json = json_encode($myArray);
echo
$json;
?>