在我的数据库中只获取一个数据但希望获得多个数据

时间:2016-09-25 11:40:08

标签: php ionic-framework

This is my database This is data i only get in my database

这是我的代码行。谢谢你的帮助:D

          in my controller where i use to store in a variable my localstorage value and use it in my php code..

          var link = 'http://127.0.0.1/mobile/subject.php';
          var userid = JSON.parse(localStorage.getItem('loginDetails'));
          console.log(userid);


          $http.post(link, {userid: userid}).success(function(res){
          console.log(res);
          })
          .error(function(err) {
          console.log(err)
          });


          And this is my subject.php code 
          <?php
          header("Access-Control-Allow-Origin: *"); 
          require_once('connection.php');

          $post_data = file_get_contents('php://input');
          $request = json_decode($post_data);
          //var_dump($post_data);

          $userid= $request->userid;

          $subject_sql ="SELECT SubjectName FROM subjects WHERE userid = '"  
         .$userid. "' ";

          $result = $con->query($subject_sql);
          $re=$result->fetch_assoc();
          echo json_encode($re);

          ?>

在我的PHP代码中,我想检索与登录系统的用户的用户ID匹配的所有主题名称。 我是所有这一切的新手..

0 个答案:

没有答案