Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

php

$sql = "SELECT * FROM food WHERE cropName = 'Rice' AND foodName = 
'Foodname1' ";
$result = mysqli_query($connect, $sql);
$num_rows = mysqli_num_rows($result);
if ($num_rows > 0) {
    $jsonData = array();
    while ($array = mysqli_fetch_row($result)) {
    $jsonData[] = $array;
  }
}
class Emp {
  public $majorFoods = "";    
   }
   $e = new Emp();
   $e->majorFoods = $jsonData;
   header('Content-type: application/json');
   echo json_encode($e);
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #php
ADD COMMENT
Topic
Name
8+3 =