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
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>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.