<?php
header('Access-Control-Allow-Origin: *');

include_once("db_connect.php");
// Check connection
if (mysqli_connect_errno())
{
	echo "Failed to connect to MySQL: " . mysqli_connect_error();
	die();
}

$query = "SELECT * FROM myorilite where status='1' ORDER BY rank DESC, product ASC";
$dbresult = mysqli_query($mysqli, $query);

$data = [];
while($row = mysqli_fetch_array($dbresult))
{
    $data[] = array(
        'id' => $row['id'],
        'product' => $row['product'],
        'desc' => $row['desc'],
        'link' => $row['link']
    );
}

mysqli_close($mysqli);

if($dbresult){
    $result = json_encode($data);              
}
else {
    $result = json_encode("{success:false}");
}
echo $result;

?>