how to create web api in php how to create web api in php how to create web api in php how to create web api in php how to create web api in php how to create web api in php how to create web api in php how to create web api in php how to create web api in php how to create web api in php how to create web api in php

 how to create web api in php how to create web api in php how to create web api in php how to create web api in php how to create web api in php how to create web api in php how to create web api in php how to create web api in php how to create web api in php how to create web api in php how to create web api in php how to create web api in php how to create web api in php how to create web api in php how to create web api in php how to create web api in php how to create web api in php how to create web api in php how to create web api in php how to create web api in php how to create web api in php how to create web api in php how to create web api in php how to create web api in php how to create web api in php how to create web api in php how to create web api in php how to create web api in php how to create web api in php how to create web api in php how to create web api in php how to create web api in php how to create web api in php how to create web api in php how to create web api in php how to create web api in php how to create web api in php how to create web api in php how to create web api in php how to create web api in php how to create web api in php how to create web api in php how to create web api in php how to create web api in php how to create web api in php how to create web api in php how to create web api in php how to create web api in php how to create web api in php how to create web api in php how to create web api in php how to create web api in php how to create web api in php how to create web api in php how to create web api in php how to create web api in php how to create web api in php how to create web api in php how to create web api in php how to create web api in php how to create web api in php how to create web api in php how to create web api in php how to create web api in php how to create web api in php how to create web api in php how to create web api in php how to create web api in php how to create web api in php how to create web api in php how to create web api in php how to create web api in php how to create web api in php how to create web api in php how to create web api in php how to create web api in php how to create web api in php how to create web api in php how to create web api in php how to create web api in php how to create web api in php how to create web api in php how to create web api in php how to create web api in php how to create web api in php how to create web api in php how to create web api in php 


/// Fetch Api In PHP



<!DOCTYPE html>

<html>

<head>

  <meta charset="utf-8">

  <meta name="viewport" content="width=device-width, initial-scale=1">

  <title></title>

</head>

<body>

  <div class="container">

    <div class="row">

      <table border="1px;">

        <?php

         include('conn.php');

$api_url = 'http://localhost/shubham/api/login_api1.php';

$json_data = file_get_contents($api_url);

$response_data = json_decode($json_data,true);

 ?>

        <tr>

          <th>S No.</th>

          <th>Email</th>

          <th>Password</th>

          

        </tr>

        <?php 

     foreach ($response_data as $user) {

       ?>

<tr>

 <td><?php  echo $user['ID']; ?></td>

 <td><?php  echo $user['email']; ?></td>

 <td><?php  echo $user['password']; ?></td>

</tr>

  <?php 

}


?>

      </table>

    </div>

  </div>

</body>

</html>





//// Fetch Api Creation


<?php 

include('conn.php');


$select="SELECT *FROM admin";

$select_sql=mysqli_query($conn,$select);

while($fetch_data=mysqli_fetch_assoc($select_sql)){

$data[]=$fetch_data;

}

if ($numrows=mysqli_num_rows($select_sql)>0) {

//$response[]=$data;

}


header('Content-Type:json/application');

echo json_encode($data);


 ?>

/////////////////////-Rest api Format-///////////////////////////


[
    {
        "ID""1",
        "email""shubham@gmail.com",
        "password""admin",
        "status""1"
    },
    {
        "ID""3",
        "email""admin@gmail.com",
        "password""2424234",
        "status""2"
    },
    {
        "ID""4",
        "email""12345@gmail.com",
        "password""123@asdf",
        "status""3"
    }
]


/////////////database/////////////////////


-- phpMyAdmin SQL Dump

-- version 5.1.3

-- https://www.phpmyadmin.net/

--

-- Host: 127.0.0.1

-- Generation Time: Jul 24, 2022 at 08:21 AM

-- Server version: 10.4.24-MariaDB

-- PHP Version: 7.4.28


SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";

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: `db_blog`

--


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


--

-- Table structure for table `admin`

--


CREATE TABLE `admin` (

  `ID` int(11) NOT NULL,

  `email` varchar(50) NOT NULL,

  `password` varchar(50) NOT NULL,

  `status` int(11) NOT NULL

) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;


--

-- Dumping data for table `admin`

--


INSERT INTO `admin` (`ID`, `email`, `password`, `status`) VALUES

(1, 'shubham@gmail.com', 'admin', 1),

(3, 'admin@gmail.com', '2424234', 2),

(4, '12345@gmail.com', '123@asdf', 3);


--

-- Indexes for dumped tables

--


--

-- Indexes for table `admin`

--

ALTER TABLE `admin`

  ADD PRIMARY KEY (`ID`);


--

-- AUTO_INCREMENT for dumped tables

--


--

-- AUTO_INCREMENT for table `admin`

--

ALTER TABLE `admin`

  MODIFY `ID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;

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 */;





Comments

Popular posts from this blog

How to upload files and input fields in php with using ajax. How to upload files and input fields in php with using ajax. How to upload files and input fields in php with using ajax.

Best computer in institute in web developer