2014-05-18 12:51
浏览 22


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) "" } 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

        $someArray =  radioCity::whereIn('chkid',$chkbox);
        return View::make('',compact('someArray'));


               <th>yada yada</th>
           @foreach($someArray as $row)
               <td>{{ $row['city'] }} </td>
               <td>{{ $row['duration'] }} </td>
               <td>{{ $row['yadayada'] }} </td>
    点赞 打赏 评论

相关推荐 更多相似问题