我想重新设计一个栏的触摸屏应用程序的键盘应用程序(我正在使用Codeigniter)。用JQUERY标签显示SQL数据
我想要的文章显示在两个部分:所有article_category的 1.列出 2.下面所选择的article_category显示ARTICLE_NAME + article_price + article_image
VINES BEERS饮料< - 类别标签
白藤标签下VINES < - 不同aricle名
红葡萄
MERLOT CABERNET
我有结构SQL表的文章: 的article_id aricle_name article_category article_price article_image
寻找一个解决方案,我发现,JQUERY标签将帮助我解决问题。
我在网上找到了CI车试玩版。我用我的数据库取代了它的数据 它的工作原理与标签相同!我列出了标签中列出的所有类别。
但我不知道如何获取选定选项卡的数据(看看category.php)?
我的文件:应用程序/控制器/ 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
}
}
我的文件:应用程序/模型/ 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();
}
}
我的文件:应用程序/视图/车/ 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>
我的文件:应用程序/视图/ 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>
@Musa:为什么减去一个?你认为这是一个无关紧要的答案吗? –
我没有投下你的答案,我编辑了它。 – Musa
对不起,如果我在错误的位置回答。我在这里是新手。 –