php - Laravel for loop error -
when receive number in controller , pass view this:
public function show(request $request) { $products = $request->products; return view('admin.administration')->with('products',$products); } and show in view this:
<div class="form-group"> @for($i=0; $i <{{ $products }}; $i++) <div class="form-group"> <label for="rol" class="col-lg-2 control-label">product:</label> <div class="col-lg-10"> <input type="text" class="form-control" id="title>" placeholder="titel" name="title>"> <input type="text" class="form-control" id="description>" placeholder="beschrijving" name="description>"> <input type="text" class="form-control" id="price>" placeholder="prijs" name="price"> <input type="text" class="form-control" id="number>" placeholder="aantal" name="number"> <input type="text" class="form-control" id="total>" placeholder="totaal" name="total"> </div> </div> @endfor </div> it throws following error:
parse error: syntax error, unexpected '?' (view: /home/vagrant/code/l/resources/views/admin/administration.blade.php)
checked dd value isn't empty. when replace {{ $products }} example 5 works. should do?
try replacing
@for($i=0; $i < {{ $products}}; $i++) with
@for($i=0; $i < $products; $i++) {{$products}} shorthand <?php echo $products; ?>
Comments
Post a Comment