簡體   English   中英

如何在HTML表格中打印多個查詢結果行?

[英]How to print more than one query result rows in html table?

我有以下代碼:

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);

我有復選框(在td中)在表的索引頁中具有動態ID,因此當用戶單擊復選框時,我將這些值發布到下一頁並將這些值發送到mysql查詢,如我上面所示(選擇多個兩行取決於用戶選擇),所以現在我要發送這些值以進行查詢以從數據庫中獲取行,並且需要在html表中打印。

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

我得到這個數組,所以我怎么打印這個

假設您使用的是雄辯的話

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

視圖

<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>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM