hi so i want to select all the available ingredients through checkbox whenever i select an option in a category (Halal,Dessert,Vegetarian and Any) but i cant apply it to my codes. can u guys help me please?
Here's my code:
Views-----> add_product.php
<div class="form-group">
<div class="col-sm-10">
<select class="form-control" name="recipe_category">
<option selected disabled>Select Recipe Category</option>
<?php foreach($this->products_model->getCategory() as $row): ?>
<option value="<?php echo $row->category_id ?>"><?php echo $row->name; ?></option>
<?php endforeach; ?>
</select>
</div>
</div>
<div class="form-group">
<div class="col-sm-10">
<label>Pick Ingredients</label>
<div class="row">
$ingredient
<?php foreach($this->products_model->getIngredientname() as $row): ?>
<div class="col-sm-3"><div class="checkbox"><label><input type="checkbox" name="ingredients[]" value="<?php echo $row->ingredient_id; ?>"><?php echo $row->name ?></label></div></div>
<?php endforeach; ?>
</div>
</div>
</div>
Model----> products_model.php
public function getIngredientname($category_id)
{
$this->db->select('ingredient_id');
$this->db->limit(1);
$this->db->where('category_id', $category_id);
$ingredientQuery = $this->db->get('category_ingredient');
$ingredient_id = $ingredientQuery->row()->ingredient_id;
$this->db->select('name');
$this->db->where('ingredient_id', $ingredient_id);
$query = $this->db->get('ingredient');
foreach($query->result() as $row)
{
return $row->name;
}
}
Controller----->dashboard.php
public function add_product() {
$this->load->view('add_product');
}
Aucun commentaire:
Enregistrer un commentaire