doudou0612 2014-05-18 12:51
浏览 25
已采纳

如何在html表中打印多个查询结果行?

I have this code:

static function mcontent($chkbox){
   $count = count($chkbox);
   foreach ($chkbox as $value){
       $count = count($value);
       for($i=0;$i>$count;$i++) {
       $sql = "SELECT * FROM `radio_city` where chkid in (\"$value[$i]\")";

   } }
return DB::select($sql);

I have checkboxes which are having dynamic ID's in index page on a table (in td),so when user clicks checkboxes then i am posting those values to next page and sending those values to mysql query as i have shown above(to select more than two rows those depends on user selection),So now i am sending those values to query to fetch the rows from database and need to print in html table.

array(8) { ["city"]=> string(1) "8" ["duration"]=> string(1) "0" ["frequency"]=> string(1) "0" ["hours"]=> string(1) "0" ["days"]=> string(1) "0" ["checkbox"]=> array(2) { [2]=> string(5) "bang2" [3]=> string(5) "bang3" } ["TotlCost"]=> string(6) "Rs 0/-" ["email"]=> string(25) "prasanna.mundas@gmail.com" } array(1) { [0]=> object(stdClass)#552 (9) { ["state"]=> string(9) "Karnataka" ["city"]=> string(9) "Bangalore" ["station"]=> string(15) "Radio Fever 104" ["language"]=> string(5) "Hindi" ["reach"]=> string(5) "7.90%" ["rate"]=> string(3) "500" ["rank"]=> string(3) "181" ["idnum"]=> int(8) ["chkid"]=> string(5) "bang3" } }

I am getting this array so how can i print this

  • 写回答

1条回答 默认 最新

  • duanfu7994 2014-05-18 21:20
    关注

    Assuming you are using eloquent and blade

    myFunction(){
        $someArray =  radioCity::whereIn('chkid',$chkbox);
        return View::make('some.page',compact('someArray'));
    }
    

    View

    <table>
        <thead>
           <tr>
               <th>City</th>
               <th>Duration</th>
               <th>yada yada</th>
           </tr>
         </thead>
         <tbody>
           @foreach($someArray as $row)
             <tr>
               <td>{{ $row['city'] }} </td>
               <td>{{ $row['duration'] }} </td>
               <td>{{ $row['yadayada'] }} </td>
             </tr>
           @endforeach
         </tbody>
    </table>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题