1

I've an review table in my database and same has been associated with the products on my website, however while posting the json encode i am unable to see multiple array through my code.

Please help me in updating the same.

<?php

if ($_SERVER['REQUEST_METHOD'] == 'GET') {
    $id = $_GET['id'];
    require('adminpanel/includes/application_top.php');
    $sql = "SELECT * FROM drug_reviewpage WHERE fld_product_id='" . $id . "'";
    $r = mysql_query($sql);
    $res = mysql_fetch_array($r);
    $result = array();
    array_push($result, array(
        "fld_review_message" => $res['fld_review_message'],
        "fld_fullname" => $res['fld_fullname'],
        "fld_rate" => $res['fld_rate'],
        "fld_date" => $res['fld_date']  
    ));
    echo json_encode(array("result"=>$result));
    mysql_close($conection);
}
?>
Sverri M. Olsen
  • 13,055
  • 3
  • 36
  • 52
  • Result which i am getting right now. {"result":[{"fld_review_message":"Hello","fld_fullname":"Meenakshi Gautam","fld_rate":"0","fld_date":"2016-03-30 04:00:04"}]} – Deepak Singh Apr 08 '16 at 10:53
  • your query is subject to sql injection. Refer http://stackoverflow.com/questions/60174/how-can-i-prevent-sql-injection-in-php – Priyank Apr 08 '16 at 11:03

0 Answers0