Pass data from view to controller |
(09-09-2019, 08:03 AM)InsiteFX Wrote: Each of your vehicle cards should have a link that goes to the controller passing the vehicle id to it.The vehicle cards are create with a foreach cycle, but creating the link is not the problem... But the main problem is how do I pass the vehicle id to the car detail view... I found various methods, but I can't figure out which one is best for me... down here you can find my vehicle and car controllers (as they are right now with all my trials). I write down also the vehicle view and my (temporary) car view. Controllers: Code: public function vehicles() <?php foreach ($vehicles as $vehicle_item): ?> <div class="col-md-4 mt-5"> <div class="card text-center"> <img class="card-img-top picture_crop" src="assets/images/cars/<?php echo $vehicle_item['id_vehicle']?>/<?php echo $vehicle_item['picture']?> " alt="<?php echo$vehicle_item['model'] ?>" href = "<?php echo base_url().'/car'.$vehicle_item['id_vehicle']?>"> <div class="card-body"> <h5 class="card-title"><?php echo $vehicle_item['brand']. ' ' .$vehicle_item['model']?></h5> <hr> <p> <li><a href = " <?php echo base_url('car/'. $vehicle_item['id_vehicle']) ?>"> Bottone <a> </p> <div class="collapse" id="collapseExample"> <div class="card card-body"> <p class="card-text"><?php echo $vehicle_item['description']?></p> <p class="card-text">Motore: <?php echo $vehicle_item['engine']?></p> <p class="card-text">Anno: <?php echo $vehicle_item['year']?></p> </div> </div> </div> <div class="card-footer text-muted"> <div class="row"> <div class="col"> <a href=""><i class="fas fa-map"></i></a> </div> <div class="col"> <a href="mailto:[email protected]"><i class="fas fa-envelope"></i></a> </div> <div class="col"> <a href="tel:+123456789"><i class="fas fa-phone"></i></a> </div> </div> </div> </div> </div> <?php endforeach; ?> </div> </div> Car view: <?php echo $vehicle['model']?> Code: Controller |
Messages In This Thread |
Pass data from view to controller - by mandiatutti - 09-09-2019, 06:18 AM
RE: Pass data from view to controller - by InsiteFX - 09-09-2019, 08:03 AM
RE: Pass data from view to controller - by mandiatutti - 09-09-2019, 08:31 AM
RE: Pass data from view to controller - by demyr - 09-09-2019, 11:23 AM
RE: Pass data from view to controller - by mandiatutti - 09-09-2019, 11:48 AM
RE: Pass data from view to controller - by demyr - 09-11-2019, 06:35 AM
RE: Pass data from view to controller - by InsiteFX - 09-11-2019, 08:07 AM
RE: Pass data from view to controller - by Wouter60 - 09-11-2019, 08:13 AM
RE: Pass data from view to controller - by InsiteFX - 09-11-2019, 05:59 PM
RE: Pass data from view to controller - by mandiatutti - 09-11-2019, 11:43 PM
|