简体   繁体   English

错误:我正在尝试在产品页面下拉列表中显示类别表中的类别名称,但显示未定义的变量,请帮帮我

[英]error: I'm trying to display categories names from category table in product page dropdown, but displaying undefined variable, please help me out

model model
here is the model where I'm selecting category name from the category table这是 model,我从类别表中选择类别名称

public function getcategorylist()
    {
        $query = $this->db->query('SELECT category_name FROM category');
        return $this->db->query($query)->result();
    }

controller controller

public function getcategorylists()
{
    $this->load->model('delivery_model');
    $data['displatcat'] = $this->Category_model->getcategorylist();
    $this->load->view('addevent', $data);
}

view看法

<select class="form-control">
 <?php foreach($displatcat as $categories){ ?>
    <option value="<?php echo $categories->category_name; ?>"><?php echo $categories->category_name; ?></option>';
<?php } ?>

The controller one. controller 一个。 Just return it like this:像这样返回它:

return $query->result();

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我正在尝试在magento的产品页面上显示面包屑,但这给了我一个致命错误 - I'm trying to display breadcrumbs on product page in magento but it gives me a fatal error 从 Woocommerce 类别下拉小部件中禁用某些产品类别 - Disable some product categories from Woocommerce category dropdown widget SQLite没有给我这样的列错误,列是我要存储到表中的变量的值 - SQLite gives me a no such column error, with the column being the value of a variable I'm trying to store into the table 我正在尝试将数据从MySQL显示到包含表格的PHP页面,但我无法在表格中显示信息 - I'm trying to display data from MySQL onto a PHP page that contains a table but I can't get the info to display inside the table 尝试从数据库填充DropDown时出现Laravel错误未定义变量 - Laravel Error undefined variable when trying to populate DropDown from database 我不明白这个错误(swiftmailer)。我已经排除了端口25仍然无法理解。 请帮帮我吗? - I could not understand this error(swiftmailer) .i have exceptioned out port 25 still coudnot understand. please help me out? Magento:在产品页面上显示产品所属的类别,但过滤出一个特定类别 - Magento: Display Category a Product Belongs to on the Product Page but Filter Out One Specific Category 数据未从PHP发布到MySQL表中。 请告诉我我在做什么错 - Data not posting in MySQL table from PHP. Please tell me what I'm doing wrong here 从woocommerce产品类别页面中删除选择一个选项下拉菜单 - remove choose an option dropdown from woocommerce product category page 下拉选择:显示带有项目的类别名称 - Dropdown Select: Displaying category names with items
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM