I want to show two foreach loop data dynamically inside one table, but the design of the table break after dynamic loop data.
My blade.php code is given below:
<table>
<tr>
<th>Name</th>
<th>Buy Rate</th>
<th>Sell Rate</th>
</tr>
<tr>
<?php foreach($datav as $data){ ?>
<td><?php echo $data->name; ?></td>
<td><?php echo $data->buy_rate; ?></td>
<?php } ?>
<?php foreach($sells as $sell){ ?>
<td><?php echo $sell->rate; ?></td>
</tr>
<?php } ?>
</table>
My route is:
Route::get('/','WelcomeController@test');
My Controller Code:
public function test(){
$datav= DB::table('localcurrency')
->where('status',1)
->get();
$sells= DB::table('localcurrency2')
->where('status',1)
->distinct()
->get();
return view('home.home_content')
->with('datav',$datav)
->with('sells',$sells);
}
How can I run this?
</tr>outside of the secondforeach.$datavand$sellsarrays or collections? Also, is this in a.blade.phpfile?