I just want the table show the category name rather than showing its ID to the user...So I just added $data['category'] object in my Controller
Controller Code:
$Query="group by product_image order by product_id";
$data["products"] = $this->insert->Select('product',$Query);
foreach ($data['products'] as $waste) {
$qry = "where id=".$waste->product_category;
$cat[] = $this->insert->select('category',$qry);
}
$data['category'] = $cat;
//print_r($data["products"]);
$this->load->view('manage/product/list',$data);
View Code:
if(!empty($products)) {
$l=0;
$base_url=$this->config->item('base_url');
$tot = count($products);
foreach($products as $products_info) {
$l++; ?>
<tr>
<td valign="middle"><div class="checkbox check-default">
<!-- <input type="checkbox" value="3" id="checkbox2" />
<label for="checkbox2"></label> !-->
</div></td>
<td valign="middle"><?php echo $products_info->product_id;?></td>
<td valign="middle"><?php echo $products_info->product_code;?></td>
<td valign="middle"><?php echo $products_info->product_name;?>-<?php echo $products_info->prod_weight;?></td>
<td valign="middle"><a target="_new" href="<?php echo $base_url. "product/".$products_info->product_image;?>"><img src="<?php echo $base_url. "product/".$products_info->product_image;?>" width="75" height="30" alt="" /></a></td>
<td valign="middle"><?php echo $products_info->product_amount; ?></td>
<td valign="middle">
<?php foreach($category as $cat) { ?>
<?php echo $cat[0]->category_title; ?>
<?php } ?>
</td>
<td><?php if($products_info->status==1) {?>
<button Placeid="<?php echo $products_info->id;?>" action='1' class="btn btn-mini btn-success status-btn">Approved</button>
<?php } else { ?>
<button Placeid="<?php echo $products_info->id;?>" action='0' class="btn btn-mini btn-danger status-btn">UnApproved</button>
<?php } ?>
</td>
The Output image of this Code =>
but I just want to show the correct category to the corresponding row..So please help to get off from this...Waiting for possible solutionzzz
No need multiple query : simple use INNER JOIN .
select * from product as p inner join category as c on p.product_category=c.id
Related
I already have a working function in my model
//GETTING TOTAL PURCHASE
function total_portal_user_sale($user_id)
{
$return = 0;
$transection = $this->db->get('transection')->result_array();
foreach ($transection as $row) {
if ($row['buyer'] == $user_id) {
$return += $row['credit'];
}
}
return $return;
}
i am getting data from my database correctly but i need to filter result by where clause for example this query
$this->db->query("SELECT sum(credit) as total FROM transection
where buyer = $user_id and status like '%paid%'");
this is the same scenario but with data filtering, I don't know how to use my query with active record statement
if someone rewrite my
function total_portal_user_sale($user_id)
with my WHERE clause query i will appreciate it ...
this is how i am rendering data into tables in view file
<div class="panel-body" id="demo_s">
<table id="demo-table" class="table table-striped" data-pagination="true" data-show-refresh="false" data-ignorecol="0,6" data-show-toggle="false" data-show-columns="false" data-search="true" data-striped="true" data-filter-control="true" data-show-export="true" >
<thead>
<tr>
<th style="width:4ex"><input type="checkbox" id="users_idtog"/></th>
<th><?php echo translate('no');?></th>
<th><?php echo translate('image');?></th>
<th><?php echo translate('name');?></th>
<th><?php echo translate('email');?></th>
<th><?php echo translate('phone');?></th>
<th>Total<br>Sale</th>
<th>This<br>Month<br>Sale</th>
<th>Total Debit</th>
<th>Total<br>Profit</th>
<th><?php echo translate('creation');?></th>
<th>Monthly<br>Sale<br>Target</th>
<th>Coupon<br>Code</th>
<th>Coupon<br>Expiry<br>Date</th>
<th class="text-right"><?php echo translate('options');?></th>
</tr>
</thead>
<tbody >
<?php
$i = 0;
foreach($all_users as $row){
$i++;
?>
<tr>
<td><input type="checkbox" class="users_id" name="users_id[]" value="<?php echo $row['user_id']; ?>" /></td>
<td><?php echo $i; ?></td>
<td>
<img class="img-sm img-circle img-border"
<?php if(file_exists('uploads/user_image/user_'.$row['user_id'].'.jpg')){ ?>
src="<?php echo base_url(); ?>uploads/user_image/user_<?php echo $row['user_id']; ?>.jpg"
<?php } else if($row['fb_id'] !== ''){ ?>
src="https://graph.facebook.com/<?php echo $row['fb_id']; ?>/picture?type=large" data-im='fb'
<?php } else if($row['g_id'] !== ''){ ?>
src="<?php echo $row['g_photo']; ?>"
<?php } else { ?>
src="<?php echo base_url(); ?>uploads/user_image/default.png"
<?php } ?> />
</td>
<td><?php echo $row['username']; ?></td>
<td><a href="mailto:<?php echo $row['email']; ?>" target="_self" ><?php echo $row['email']; ?></td>
<td><?php echo $row['phone']; ?></td>
<td class="text-right"><?php echo $this->crud_model->total_purchase($row['user_id']); ?></td>
<td class="text-right">
<?php
$Days = explode("-",date("d-m-Y"));
echo round($this->crud_model->sale_target($Days[0],$row['user_id']),2);
?>
</td>
<td class="text-right"><?php echo $this->crud_model->total_profit($row['user_id']); ?></td>
<?php
$ts = $this->crud_model->total_portal_user_sale($row['user_id']);
$tc = $this->crud_model->total_portal_user_profit($row['user_id']);
$tp = $ts - $tc
?>
<td class="text-right">
<?php echo $ts; ?>
</td>
<td class="text-right"><?php echo date('d M,Y',$row['creation_date']);?></td>
<td><?php echo $row['monthly_sale_target']; ?></td>
<td><?php echo $row['coupon_code']; ?></td>
<td><?php echo $row['expiry_date']; ?></td>
<td class="text-right">
<a class="btn btn-purple btn-xs btn-labeled fa fa-tag" data-toggle="tooltip"
onclick="ajax_modal('add_discount','<?php echo translate('give_target_discount'); ?>','<?php echo translate('adding_discount!'); ?>','add_discount','<?php echo $row['user_id']; ?>')" data-original-title="Edit" data-container="body">
<?php echo translate('give_discount');?>
</a>
<a class="btn btn-success btn-xs btn-labeled fa fa-wrench" data-toggle="tooltip"
onclick="ajax_modal('edit','<?php echo translate('edit_user'); ?>','<?php echo translate('successfully_edited!'); ?>','user_edit','<?php echo $row['user_id']; ?>')"
data-original-title="Edit" data-container="body">
<?php echo translate('edit');?>
</a>
<a onclick="delete_confirm('<?php echo $row['user_id']; ?>','<?php echo translate('really_want_to_delete_this?'); ?>')" class="btn btn-xs btn-danger btn-labeled fa fa-trash" data-toggle="tooltip"
data-original-title="Delete" data-container="body">
<?php echo translate('delete');?>
</a>
</td>
</tr>
<?php
}
?>
</tbody>
</table>
</div>
Hope this will help you :
function total_portal_user_sale($user_id)
{
$return = 0;
$this->db->select('*');
//$this->db->select('sum(credit) as total,buyer');
$this->db->from('transection');
$this->db->where('buyer',$user_id);
$this->db->like('status','paid');
$query = $this->db->get();
if ($query->num_rows() > 0 )
{
foreach ($query->result_array() as $row)
{
if ($row['buyer'] == $user_id)
{
$return += $row['credit'];
}
}
return $return;
}
}
You can also use $this->db->select_max('credit') for the same
For more : https://www.codeigniter.com/user_guide/database/query_builder.html
My delete button is not working.
For a view file it's working - this is my code for view_file.php:
<?php
$sql_id="SELECT * FROM meeting_info where id=".$id ;
`$result2 = $conn->query($sql_id);
if($row2 = $result2->fetch_assoc()) {
$bilno = $row2['bilno'];
}
?>
<body>
<div id="body">
<table align="center" width="90%">
<tr>
<th colspan="6">
<div align="center">
<h3>Meeting Bil.No
<?php echo $bilno; ?> </h3>
</div>
</th>
</tr>
<tr bgcolor="#3366ff">
<td>Bil. Item</td>
<td>File Type</td>
<td>File Size (KB)</td>
<td>View</td>
<td>Edit</td>
<td>Delete</td>
</tr>
<?php
$sql="SELECT * FROM meeting_details where id=".$id ." order by item_no asc";
$result = $conn->query($sql);
while($row = $result->fetch_assoc())
{
if($j%2 == 1) {$colortd = "#99ccff";
}
else {$colortd = "#f5f5f0";}
?>
<tr bgcolor=<?php echo $colortd;?>>
<td>
<?php echo $row['item_no'] ?>
</td>
<td>
<?php echo $row['type'] ?>
</td>
<td>
<?php echo $row['size'] ?>
</td>
<td>
<a class="btn btn-view" href="uploads/<?php echo $row['file']; ?>" target="_blank" alt="<?php echo $row['item_no']; ?>" title="click for edit">
<center><img src="images\iconview.png"></center>
</a>
</td>
<td>
<a class="btn btn-info" href="edit_file.php?edit=<?php echo $row['id']; ?>" title="click for edit" onclick="return confirm('sure to edit ?')">
<center><img src="images\iconedit.png"></center>
</td>
<td>
<a class="btn btn-danger" href="delete_file.php?delete=<?php echo $row['id']; ?>" title="click for delete" onclick="return confirm('sure to delete ?')">
<center><img src="images\icondel.png"></center>
</td>
</tr>
<?php
$j++;
}
//$conn->close();
?>
</table>
</div>
</body>
For the delete button, I want to delete all rows on information that I want to delete. But it's not working. When i click the delete button it's just come out the blank page. The data still have in database and website.
This my delete_file.php code:
<?php
include("db_conn.php");
if (isset($_GET['id']) && is_numeric($_GET['id']))
{
$id =$_GET['id'];
$sql = "DELETE FROM meeting_details WHERE id=".$id;
$result = $conn->query($sql);
}
$conn->close();
?>
Check this line:
<a class="btn btn-danger" href="delete_file.php?delete=<?php echo $row['id']; ?>" title="click for delete" onclick="return confirm('sure to delete ?')">
here the delete url is like: delete_file.php?delete=1 and you are fetching the value like:
$id =$_GET['id'];
So change it to:
$id =$_GET['delete'];
and try again.
Note: Your code is wide open to SQL injection
hi all my name is Fadil Raditya
i am stuck in some code in php. I really need help.
i want add item in chart from selected item how ever it can not increment.
this is some of my code.
<?php session_start();
require_once("dbcontroller.php");
$db_handle = new DBController();
if(!empty($_GET["action"])) {
switch($_GET["action"]) {
case "add":
if(!empty($_POST["quantity"])) {
$productByCode = $db_handle->runQuery("SELECT * FROM tblproduct WHERE code='" . $_GET["code"] . "'");
$itemArray = array($productByCode[0]["code"]=>array('name'=>$productByCode[0]["name"], 'code'=>$productByCode[0]["code"], 'quantity'=>$_POST["quantity"], 'price'=>$productByCode[0]["price"]));
if(!empty($_SESSION["cart_item"])) {
if(in_array($productByCode[0]["code"],$_SESSION["cart_item"])) {
foreach($_SESSION["cart_item"] as $k => $v) {
if($productByCode[0]["code"] == $k)
{
$_SESSION["cart_item"][$k]["quantity"] = $_POST["quantity"];
}
}
}
else {
$_SESSION["cart_item"] = array_merge($_SESSION["cart_item"],$itemArray);
}
} else {
$_SESSION["cart_item"] = $itemArray;
}
}
break;
and i want call adding the quantity when hit the add chart button
<?php
$product_array = $db_handle->runQuery("SELECT * FROM tblproduct ORDER BY id DESC");
if (!empty($product_array)) {
foreach($product_array as $key=>$value){
?>
<div class="col-xs-6 col-sm-3 col-md-3">
<div class="team-wrapper-big">
<form method="post" action="index.php?action=add&code=<?php echo $product_array[$key]["code"]; ?>">
<h6><?php echo $product_array[$key]["name"]; ?></h6>
<img src="<?php echo $product_array[$key]["image"]; ?>">
<?php echo "Rp ".$product_array[$key]["price"]; ?>
<hr>
<img src="img/VIEW.png">
<input type="text" name="quantity" value="1" placeholder="quantity in number" />
<input type="submit" value="Add to cart" class="btnAddAction" src="img/BUY.png">
<hr>
</form>
</div>
</div>
<?php
}
}
?>
This is the ouput source
<div id="shopping-cart">
<div class="txt-heading"></div>
<?php
if(isset($_SESSION["cart_item"])){
$item_total = 0;
?><center>
<table cellpadding="10" cellspacing="3" border="1">
<tbody>
<tr>
<th><strong>Name</strong></th>
<th><strong>Code</strong></th>
<th><strong>Quantity</strong></th>
<th><strong>Price</strong></th>
<th><strong>Total Price</strong></th>
<th><strong>Action</strong></th>
</tr>
<?php
foreach ($_SESSION["cart_item"] as $item){
?>
<tr>
<td><strong><?php echo $item["name"]; ?></strong></td>
<td><?php echo $item["code"]; ?></td>
<td><?php echo $item["quantity"]; ?></td>
<?php $_SESSION["track"] = $item["quantity"]; ?>
<td align=right><?php echo "Rp. ".$item["price"]; ?></td>
<td align=right><?php echo "Rp. ".$item["quantity"]*$item["price"]; ?></td>
<td>Remove Item</td>
</tr>
<?php
$item_total += ($item["price"]*$item["quantity"]);
}
?>
<tr>
<td colspan="6" align=right><strong>Total:</strong> <?php echo "Rp. ".$item_total; ?></td>
</tr>
</tbody>
</table> </center>
<?php
}
?><a id="btnEmpty" href="index.php?action=empty">Empty Cart</a>
</div>
i hope anyone can help me. need suggestion and solution. open to discussion.
regards
Fadil Raditya
I have a code :
<?php
getPriceListHeader();
function getPriceListDetail($PriceListCode)
{
$resource = Mage::getSingleton('core/resource');
$readConnection = $resource->getConnection('core_read');
$query = "SELECT * FROM pricelisdetail where pricelist_code='".$PriceListCode."'";
$results = $readConnection->fetchAll($query);
echo "<table id='tbdata'>
<thead>
<tr>
<th>Price List Code</th>
<th>Price List Name</th>
<th>Effective From</th>
<th>Effective To</th>
</tr>
</thead>
<tbody> ";
foreach ($results as $row)
{
echo "<tr>";
echo "<td> ".$row[entity_id];
echo "<td> ".$row[sku];
echo "<td> ".$row[sku];
echo "<td> ".$row[sku];
};
echo " </tbody>
</table> ";
}
function getPriceListHeader()
{
$resource = Mage::getSingleton('core/resource');
$readConnection = $resource->getConnection('core_read');
$query = 'SELECT * FROM pricelistheader';
$results = $readConnection->fetchAll($query);
echo "
<h2>Price List</h2>
<div>
<h3>Please select Price List</h3>
<div>
<select class='element select large' id='pricelist' name='element_2'>";
foreach ($results as $row)
{
echo '<option value="' . $row[entity_id]. '">' . $row[sku] . '</option>';
}
echo "</select>
</div>
<input type='button' class='button' name='insert' value='Get Data' onclick='getPriceListDetail(pricelist.value)'/>
";
getPriceListDetail('');
}
?>
I have a dropdown list, a button, a table
When I select a value from dropdown list, then I click button , table will be filled data again. There are 2 method, getPriceListHeader(): load data header when load the page, getPriceListDetail : load data detail when click a button. I try to put event getPriceListDetail(value) to button, but when I click, nothing happens
Please help me how to do this.
Yes, you can call php via ajax request to server like this (very simple):
Note that the following code uses jQuery
jQuery.ajax({
type: "POST",
url: 'my_php_function.php',
dataType: 'name_the_data_type',
success: function (data) {
// here you will get the response your function
}
});
and my_php_function.php like this:
<?php
// here is your php code or function
?>
from the source How can I call PHP functions by JavaScript?
You can't attach PHP function to HTML. PHP is server-side language, so after it's displayed in users browser you can't refer to PHP again, unless you reload page.
There are 3 options I think you can do:
Reload page after changing select page and using GET prepare new data.
Send all data to user browser and than show only part of it related to selected option.
Use AJAX and ask server for new data in background.
Finally, I found out the way.It works for me. Now, I do not understand the code , I am trying to read and get it clearly.
Thanks all for your comments.
$to="";
$from="";
$show_order_statuses = 0;
$orserstatus = "";
$result_order = 0;
//var_dump($results);
//return;
if(!empty($_REQUEST['filter_type']))
{
$orders_row = array();
$filter_type = $_REQUEST['filter_type'];
$resource = Mage::getSingleton('core/resource');
$readConnection = $resource->getConnection('core_read');
$query = " SELECT * FROM pricelistitem where pricelist_code='".$filter_type."' ";
// $query = 'SELECT * FROM pricelistheader1';
$results = $readConnection->fetchAll($query);
foreach ($results as $rowid)
{
$result_order=10;
$orders_row[]=array($rowid['pricelist_code'],$rowid['product_code'],number_format( $rowid['unitprice'],2),$rowid['UOM']);
// $orders_row[]=array(1,1,1,1,1);
}
}
?>
<div id="anchor-content" class="middle">
<div id="page:main-container">
<div class="content-header">
<table cellspacing="0">
<tbody>
<tr>
<td style="width:50%;"><h3 class="icon-head head-report-sales-sales"><?php echo $this->__("Price List");?></h3></td>
<td class="form-buttons"><button style="" onclick="filterFormSubmit.submit()" class="scalable " type="button" id="id_<?php echo Mage::getSingleton('core/session')->getFormKey() ?>"><span>Show Report</span></button></td>
</tr>
</tbody>
</table>
</div>
<div>
<div class="entry-edit">
<form method="get" action="<?php echo Mage::helper('core/url')->getCurrentUrl();?>" id="filter_form">
<?php /*?><input name="form_key" type="hidden" value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" /><?php */?>
<div class="entry-edit-head">
<h4 class="icon-head head-edit-form fieldset-legend">Filter</h4>
<div class="form-buttons"></div>
</div>
<div id="sales_report_base_fieldset" class="fieldset">
<div class="hor-scroll">
<table cellspacing="0" class="form-list">
<tbody>
<tr>
<td class="label"><label for="sales_report_filter_type">Filter By <span class="required">*</span></label></td>
<td class="value">
<select class="required-entry select" name="filter_type" id="sales_report_filter_type" onchange="myFunction();">
<?php
$resource = Mage::getSingleton('core/resource');
$readConnection = $resource->getConnection('core_read');
$query = " SELECT * FROM pricelistheader ";
$results = $readConnection->fetchAll($query);
$so=1;
foreach ($results as $row)
{
$selected='';
if ($filter_type==$row[pricelist_code])
$selected= ' selected=selected';
else
$selected='';
echo '<option value="' . $row[pricelist_code]. '" '.$selected.' >' . $row[pricelist_name].' '. $row[pricelist_code] . '</option>';
}
?>
</select>
</tr>
<tr>
<td class="label"><label for="effect_from">Effect From </label></td>
<td class="value">
<?php
foreach ($results as $row)
{
if ($filter_type==$row[pricelist_code])
echo $row[pricelist_fromdate];
}
?>
</td>
</tr>
<tr>
<td class="label"><label for="effect_from">Effect To </label></td>
<td class="value">
<?php
foreach ($results as $row)
{
if ($filter_type==$row[pricelist_code])
echo $row[pricelist_todate];
}
?>
</td>
</tr>
</tbody>
<script>
function myFunction() {
// document.getElementById("tbdata").deleteRow(1);
var rowCount = tbdata.rows.length;
for (var i = rowCount - 1; i > 0; i--) {
tbdata.deleteRow(i);
}
srt.value=pricelist.options[pricelist.selectedIndex].value;
";
//$('#tbdata').empty();
}
</script>
</table>
</div>
</div>
</form>
</div>
<script type="text/javascript">
//<![CDATA[
var filterFormSubmit = new varienForm('filter_form');
//]]>
</script>
<script type="text/javascript"> new FormElementDependenceController({"sales_report_order_statuses":{"sales_report_show_order_statuses":"1"}}); </script>
<style type="text/css">
.no-display{display:none;}
</style>
</div>
<div>
<?php if($result_order>0){?>
<table cellspacing="0" class="actions">
<tbody>
<tr>
<td class="pager"> </td>
<td class="export a-right">
<form method="post" action="<?php echo $this->getUrl('*/*/exportCsv')?>" id="csv_form_customer">
<input name="form_key_customer" type="hidden" value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" />
</form>
<script type="text/javascript">
//<![CDATA[
var csvFormSubmitcustomer = new varienForm('csv_form_customer');
//]]>
</script>
</td>
<td class="filter-actions a-right">
<img class="v-middle" alt="" src="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);?>skin/adminhtml/default/default/images/icon_export.gif"> Export to:
<select style="width:8em;" id="sales_order_grid_export_customer" name="sales_order_grid_export_customer">
<option value="<?php echo $this->getUrl('*/*/exportCsv')?>">CSV</option>
</select>
<button onclick="csvFormSubmitcustomer.submit()" class="scalable task" type="button"><span>Export</span></button>
</td>
</tr>
</tbody>
</table>
<?php } ?>
<div id="id_customer<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" class="print_customer<?php echo Mage::getSingleton('core/session')->getFormKey() ?>">
<div class="grid">
<div class="hor-scroll">
<table cellspacing="0" id="id_customer<?php echo Mage::getSingleton('core/session')->getFormKey() ?>_table" class="data">
<colgroup>
<col>
<col>
</colgroup>
<thead>
<tr class="headings">
<th class=" no-link"><span class="nobr">Price List Code</span></th>
<th class=" no-link"><span class="nobr">Cust Code</span></th>
<th class=" no-link"><span class="nobr">Cust Name</span></th>
</tr>
</thead>
<tbody id="">
<?php
$resource = Mage::getSingleton('core/resource');
$readConnection = $resource->getConnection('core_read');
$query = " SELECT * FROM " . $resource->getTableName('catalog/product');;
$customercount=0;
$customerresults = $readConnection->fetchAll($query);
$customerresults = Mage::getModel('customer/customer')
->getCollection()
->addAttributeToSelect('*')
->addAttributeToFilter('erp_pricelistcode_1', $filter_type)
// ->addFieldToSelect (array('created_at','customer_id','increment_id','updated_at','status','entity_id','state'))
;
// ->addAttributeToFilter('erp_pricelistcode_1','00')->load();
$so=1;
foreach ($customerresults as $row) {
$customercount++;
}
// var_dump(#$customerresults);
if($customercount>0){
foreach($customerresults as $singlerows){
$cot=0;
{
echo "<tr>";
{
$cot++;
?>
<td>
<?php
echo $singlerows->getData('erp_pricelistcode_1');
?>
</td>
<td>
<?php
echo $singlerows->getFirstname();
?>
</td>
<td>
<?php
echo $singlerows->getName();
?>
</td>
<?php
}
echo "</tr>";
}
}
}else{
?>
<tr class="even">
<td colspan="13" class="empty-text a-center">No records found.</td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</div>
<div>
<?php if($result_order>0){?>
<table cellspacing="0" class="actions">
<tbody>
<tr>
<td class="pager"> </td>
<td class="export a-right">
<form method="post" action="<?php echo $this->getUrl('*/*/exportCsv')?>" id="csv_form">
<input name="form_key" type="hidden" value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" />
</form>
<script type="text/javascript">
//<![CDATA[
var csvFormSubmit = new varienForm('csv_form');
//]]>
</script>
</td>
<td class="filter-actions a-right">
<img class="v-middle" alt="" src="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);?>skin/adminhtml/default/default/images/icon_export.gif"> Export to:
<select style="width:8em;" id="sales_order_grid_export" name="sales_order_grid_export">
<option value="<?php echo $this->getUrl('*/*/exportCsv')?>">CSV</option>
</select>
<button onclick="csvFormSubmit.submit()" class="scalable task" type="button"><span>Export</span></button>
</td>
</tr>
</tbody>
</table>
<?php } ?>
<div id="id_<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" class="print_<?php echo Mage::getSingleton('core/session')->getFormKey() ?>">
<div class="grid">
<div class="hor-scroll">
<table cellspacing="0" id="id_<?php echo Mage::getSingleton('core/session')->getFormKey() ?>_table" class="data">
<colgroup>
<col>
<col>
<col>
<col>
</colgroup>
<thead>
<tr class="headings">
<th class=" no-link"><span class="nobr">Price List Code</span></th>
<th class=" no-link"><span class="nobr">Product Code</span></th>
<th class=" no-link"><span class="nobr">Unit Price</span></th>
<th class=" no-link"><span class="nobr">UOM</span></th>
</tr>
</thead>
<tbody id="">
<?php
$cot=0;
if(count($orders_row)>0){
foreach($orders_row as $singlerows){
$cot=0;
if(!empty($singlerows)){
echo "<tr>";
foreach($singlerows as $value){
$cot++;
?>
<td>
<?php
if ($cot==3 )
echo "<div style='float:right;width:30%;'>";
echo $value;
echo "</div>";
?>
</td>
<?php
}
echo "</tr>";
}
}
}else{
?>
<tr class="even">
<td colspan="13" class="empty-text a-center">No records found.</td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
I have the problem with update function in CodeIgniter. The cart is not updating and don't understand why. Can you help me to find a solution for this issue?
This is my Update function
public function update($in_cart = null) {
$data = $_POST;
$this->cart->update($data);
//show cart page
redirect('cart','refresh');
}
This is my form inside sidebar.php
<form action="cart/update" method="POST">
<table cellpadding="6" cellspacing="1" style="width:100%" border="0">
<tr>
<th>QTY</th>
<th>Item Description</th>
<th style="text-align:right">Item Price</th>
</tr>
<?php $i = 1; ?>
<?php foreach ($this->cart->contents() as $items) : ?>
<input type="hidden" name="<?php echo $i.'[rowid]'; ?>" value="<?php echo $items['rowid']; ?>" />
<tr>
<td><input type="text" style="color:black; text-align:center;margin-bottom:5px;" name="<?php $i.'[qty]'; ?>" value="<?php echo $items['qty']; ?>" maxlength="3" size="3"></td>
<td><?php echo $items['name']; ?></td>
<td style="text-align:right"><?php echo $this->cart->format_number($items['price']); ?></td>
</tr>
<?php $i++; ?>
<?php endforeach; ?>
<tr>
<td></td>
<td class="right"><strong>Total</strong></td>
<td class="right" style="text-align:right">$<?php echo $this->cart->format_number($this->cart->total()); ?></td>
</tr>
</table>
<br>
<p><button class="btn btn-default" type="submit">Update Cart</button>
<a class="btn btn-default" href="cart">Go to Cart</a></p>
</form>
Try using $this->input->post() to get all form posted data.
https://ellislab.com/codeigniter/user-guide/libraries/input.html