douketangyouzh5219 2016-09-25 11:40
浏览 20

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

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

This my line of code. Thank you for any help :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);

          ?>

In my php code i want to retrieve all subject name that match with the userid of the user who login into the system. I am new to all of this ..

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 数学建模招标中位数问题
    • ¥15 phython路径名过长报错 不知道什么问题
    • ¥15 深度学习中模型转换该怎么实现
    • ¥15 HLs设计手写数字识别程序编译通不过
    • ¥15 Stata外部命令安装问题求帮助!
    • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
    • ¥15 TYPCE母转母,插入认方向
    • ¥15 如何用python向钉钉机器人发送可以放大的图片?
    • ¥15 matlab(相关搜索:紧聚焦)
    • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计