Simple PHP JSON Web Service and MySQL

Database
-- phpMyAdmin SQL Dump
-- version 4.8.2
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Jan 22, 2019 at 03:40 PM
-- Server version: 10.1.34-MariaDB
-- PHP Version: 7.2.8

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET AUTOCOMMIT = 0;
START TRANSACTION;
SET time_zone = "+00:00";


/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;

--
-- Database: `bdname`
--

-- --------------------------------------------------------

--
-- Table structure for table `table_refresh`
--

CREATE TABLE `table_refresh` (
  `uniqueid` int(11) NOT NULL,
  `firstname` text NOT NULL,
  `surname` text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `table_refresh`
--

INSERT INTO `table_refresh` (`uniqueid`, `firstname`, `surname`) VALUES
(31, 'test', 'test2');

--
-- Indexes for dumped tables
--

--
-- Indexes for table `table_refresh`
--
ALTER TABLE `table_refresh`
  ADD PRIMARY KEY (`uniqueid`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `table_refresh`
--
ALTER TABLE `table_refresh`
  MODIFY `uniqueid` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=32;
COMMIT;

/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;


Data.php

query($sql);
	$r=array();
	while($row = mysqli_fetch_array($result))
	{
		$r[] = $row;
	}
	echo json_encode($r);
	?>

getdata.php


id data2 data3

Posting Komentar