Category : foreach

I want to display data in different sections, but error when I run. enter image description here Controller class Dfkamar extends CI_Controller { public function index() { $data[‘tamu’] = $this ->m_tamu->daftar_kamar()->result(); $this->load->view(‘templates/header’); $this->load->view(‘templates/sidebar’); $this->load->view(‘dfkamar’, $data); $this->load->view(‘templates/footer’); } View <?php foreach ($tamu as $tamu) : ?> <button type="button" class="btn btn-success"><?php echo $tamu->gateA ?></button> </div> <?php endforeach;?> ..

Read more

new to php and wanted to know if there was an easy way to fix this problem. $class_1 = array("Name" => "Lule", "Surname" => "Mirela", "Email" => "[email protected]", "Birthday" => "30/04/2001"); $class_2 = array("Name" => "Aida", "Surname" => "Besim", "Email" => "[email protected]", "Birthday" => "16/11/2001"); $class_3 = array("Name" => "Flaka", "Surname" => "Agim", "Email" => ..

Read more

Hello i use 3 foreach to get my final result. Can i optimize the code using only one or 2 foreach instead of 3 Any help will be helpful. Thanks <?php $checkout = new Checkout(); $recap = array(); foreach($this->comingCheckout as $item){ $checkout->get($item["id"]); $dishes = $checkout->getDishes(); foreach($dishes as $i){ $dish = new Dish(); $dish->get($i["dish_id"]); $element = ..

Read more

I am trying to generate these attributes ?, i so that I can use it in my prepared query id_product in ($strMarcas) $stmt->bind_param($strTipos, …$inputItems); but it is generating the following errors: Warning: Only arrays and Traversables can be unpacked in: explode() expects parameter 2 to be string, array given in $stmt->bind_param($strTipos, …$inputItems); Warning: Wrong parameter ..

Read more