Sunda Cyber Army


* Sunda Cyber Army 2k17 *
Indonesia Defacer ~


Path : /home/dent/public_html/acad276/
File Upload :
Current File : /home/dent/public_html/acad276/sql_to_json.php

<?php
$host = "webdev.iyaclasses.com";
$userid = "[youruserid]";
$userpw = "[yourpw]";
$db = "[database name]";

include '../pdloginvariables.php';

$mysql = new mysqli(
    $host,
    $userid,
    $userpw,
    $db
);

// because there may be special characters in the database data (there are), make sure to set a charset
$mysql->set_charset("utf8");

if($mysql->connect_errno) {
    echo "db connection error : " . $mysql->connect_error;
    exit();
}

//default sql query with limit of 50 records
if(empty($sql)) {
    $sql = 		"SELECT * FROM movieView where rating='PG' ORDER BY title LIMIT 50";
}

$results = $mysql->query($sql);

if(!$results) {
    echo "SQL error: ". $mysql->error;
    exit();
}

//  setup -- create $json_array as a variable that will contain array data
$json_array = array();

while($currentrow = $results->fetch_assoc()) {
    // print_r($currentrow);
    // command $json_array[] would add one new row to $json_array
      $json_array[] = $currentrow;
}

// Once you have populated $json_array can test it with
   // echo "<pre>";
  //  print_r($json_array);
   // echo "</pre>";

    $json2 = json_encode($json_array, JSON_UNESCAPED_UNICODE);
  //  echo $json2;