0

I need some help because my getRecipe.php is not showing the parameters or data shown like my other PHP files: getCourseType. It just appears blank and doesn't show anything in my browser.With the getRecipe.php it just display blank or nothing but I'm expecting the output like the image below for my getRecipe.php Perhaps you can modify my codes, answer it below and let me check it out if it works. Can you help me display those data of getRecipe.php from the database? thanks !

Screenshot of getCourseType(Which is working)

enter image description here

getRecipe.php

  <?php
  require_once 'include/DB_Connect.php';
  $db = new Db_Connect();
  $conn = $db->connect();
  if(isset($_GET['recipeId'])){
     $id = $_GET['recipeId'];
     $result = $conn->query("SELECT * FROM recipe where id=$id");
  }else{    
      $result = $conn->query("SELECT * FROM recipe");
  }

  if ($result->num_rows > 0) {
      $list = array();
      while($row = $result->fetch_assoc()) {
          array_push($list, $row);
      }
      echo json_encode(array('result' => $list));
  } else {
      echo json_encode("no result");
  }
  ?>

Screenshot of PHPMYADMIN Recipe

Yeah, it has data so it should display whenever I call it....

enter image description here

1
  • You might have an error on the page and turned off error reporting. Turn it on for level E_ALL, on the very beginning of the script, and see if it tells something - php.net/manual/en/function.error-reporting.php Commented Apr 17, 2016 at 8:41

1 Answer 1

1

try exemple like that :

 $id_user=$_POST['id_user'];
 $bdd = new PDO('mysql:host=localhost;dbname=db_name', 'root', '');
 $req = $bdd->prepare('select  *  from event where id_user = ?');
 $req->execute(array($id_user));
//$_SESSION['id']

   $response["events"] = array();

  while(  $donnees = $req->fetch()){
    $endroits = array();
    $endroits ['titre']=$donnees['titre'];
    $endroits ['date']=$donnees['date'];


    array_push($response["events"], $endroits);
   }

 print  json_encode($response);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.