我想将键盘应用程序重新设计为酒吧的触摸屏应用程序(我正在使用 Codeigniter)。
我希望文章分两部分显示:1.所有article_category的列表2.在选择article_category的选项卡下方显示article_name+article_price+article_image
葡萄藤啤酒饮料<-类别
WHITE VINE <-选项卡 VINES 下的不同文章名称
红藤
梅洛赤霞珠
我有带有结构的 SQL 表文章:article_id aicle_name article_category article_price article_image
在寻找解决方案时,我发现 JQUERY 选项卡可以帮助我解决问题。
我在网上找到了 CI 购物车演示。我用我的替换了它的数据库。它按标签的预期工作!我得到了标签中列出的所有类别。
但我不知道如何获取选定选项卡的数据(查看 category.php)?
我的文件:app/controllers/cart.php
<?php
class Cart extends Controller { // Our Cart class extends the Controller class
function Cart()
{
parent::Controller(); // We define the the Controller class is the parent.
$this->load->model('cart_model'); // Load our cart model for our entire class
}
function index()
{
$data['categories'] = $this->cart_model->retrieve_category(); // Retrieve an array with all categories
$data['products'] = $this->cart_model->retrieve_products(); // Retrieve an array with all products
$data['content'] = 'cart/categories'; // Select view to display
$this->load->view('index', $data); // Display the page
}
}
我的文件:app/models/cart_model.php
<?php
class Cart_model extends Model {
// Function to retrieve an array with all product information
function retrieve_products(){
$query = $this->db->get('phppos_item_kits');
return $query->result_array();
}
// Function to retrieve an array with all product information
function retrieve_category(){
$this->db->select('distinct(category)');
$this->db->from('phppos_item_kits');
$query = $this->db->get();
return $query->result_array();
}
}
我的文件:app/views/cart/categories.php
<head>
<link href="<?php echo base_url(); ?>assets/js/base/jquery-ui.css" media="screen" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="<?php echo base_url(); ?>assets/js/jquery-1.8.2.js"></script>
<script type="text/javascript" src="<?php echo base_url(); ?>assets/js/base/jquery-ui.js"></script>
<script>
$(document).ready(function() {
$("#tabs").tabs({event: "mouseover"});
});
</script>
</head>
<div id="tabs">
<ul>
<?php foreach($categories as $c): ?>
<li><a href="#fragment"><span><?php echo $c['category']; ?></span></a></li>
<?php endforeach;?>
</ul>
<div id="fragment">
<?php foreach($products as $p): ?>
<li><?php echo $p['name']; ?>,<?php echo $p['category']; ?></li>
<?php endforeach;?>
</div>
</div>
我的文件:app/views/index.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xml:lang="en-us" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>CodeIgniter Shopping Cart</title>
<link href="<?php echo base_url(); ?>assets/js/base/jquery-ui.css" media="screen" rel="stylesheet" type="text/css"/>
<link href="<?php echo base_url(); ?>assets/css/core.css" media="screen" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="<?php echo base_url(); ?>assets/js/jquery-ui.min.js"></script>
<script type="text/javascript" src="<?php echo base_url(); ?>assets/js/jquery-1.8.2.min.js"></script>
<script type="text/javascript" src="<?php echo base_url(); ?>assets/js/core.js"></script>
</head>
<body>
<div>
<?php $this->view($content); ?>
</div>
</body>
</html>