I want to pass row fetched from database to view from controller.
foreach ($usertable->result() as $note) {
$note['title'];
$this->load->view('note',$note);
}
but it didn't work.
Strictly, not the right way to send data to view (not inside for loop). This will load the view the numbers of time the loop runs.
Enclosed all the notes data into a variable say via an array data['notes'] and the now in view you can use notes variable for fetching data. Read docs for more info.
In controller:
$data['notes'] = $usertable->result();
$this->load->view('note', $data);
In view:
<table>
<tr>
<td>Note id</td>
<td>title</td>
</tr>
<?php foreach($notes as $n) { ?>
<tr>
<td><?php echo $n->id; ?></td>
<td><?php echo $n->title; ?></td>
</tr>
<?php } ?>
</table>
you can use following.
foreach ($usertable->result() as $note) {
$note[]=$note;
}
$note['title'];
$this->load->view('note',$note);
Related
i am using jquery datatable to show records in codeigniter. but i am getting all 20000 records at time. i want to get records from db page by page
my view file
<table class="table table-bordered table-striped" id="ref_tbl">
<thead>
<th>Record Id</th>
<th>User Id</th>
<th>Name</th>
</thead>
<tbody>
<?php
$srno = 1;
foreach ($companyd as $us):
?>
<tr>
<td><?php echo $srno++; ?></td>
<td><?php echo $us['comp_id']; ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
controller---
public function allusers() {
$data['companyd'] = $this->admin_model->query("SELECT * FROM tbl_company limit 100");
$this->load->view('admin/companyview', $data);
}
i am new at codeigniter. i tried to set limit. but i want pass page number to limit query. please anyone have know the how to solve this problem
try this:
//controller
public function allusers() {
$data['companyd'] = $this->admin_model->get_all_users();
$this->load->view('admin/companyview', $data);
}
//model
function get_all_users(){
return $this->db->get('tbl_company')->limit('100')->result_array();
}
I would like to generate many QR code using
"Simple QrCode"
https://www.simplesoftware.io/docs/simple-qrcode
I can make one QR code like this
{!! QrCode::size(100)->generate('http://www.mywebsite.com') !!}
but how do I make alot.
I'm beginer this code looks not good. sorry.
I can make loop but loop numbers doesn't work.
<table border="1">
<?php
for ($i=1; $i<5; $i++) {
$url = "http://localhost/acex/1.php?g=". $i;
$qr = '{!! QrCode::size(100)->generate(' . $url .') !!}';
echo "link ";
echo"<br>";
?>
<tr>
<td>
<?php
echo "link ";
?>
</td>
<td>
<?php
echo $qr;
?>
</td>
<td>
<?php
echo $url;
?>
</td>
</tr>
<?php
}
?>
</table>
As you already use SimpleSoftwareIO, just write:
use SimpleSoftwareIO\QrCode\BaconQrCodeGenerator;
and put this code in your loop:
$qrcode = new BaconQrCodeGenerator;
$qrcode->size(100)->generate("your text", 'path to save file');
It worked for me.
In my controller I'm displaying records in a table in my View.
Controller:
$promotion = Promotions::paginate(5);
View:
<tr>
<th>Order</th>
<th>Infomation</th>
<th>Date</th>
<th>Cost</th>
<th>From</th>
</tr>
</thead>
<tbody align="center">
<?php $i = 0;?>
#foreach ( $promotion as $promo)
<?php $i++;?>
<tr>
<td data-title="Order">{{$i}}</td>
<td data-title="Infomation">{{$promo['name']}}</td>
<td data-title="Date">29/10/57</td>
<td data-title="Cost">1.99$</td>
<td data-title="From">K-Bank</td>
</tr>
#endforeach
</tbody>
It works properly when I locate manually to exampleurl/mypage?page=2
All seems well. However, I wanted to create two text buttons to go back and fourth between pages.
How can I set these to navigate the pagination back and fourth:
Previous
Next
EDIT: I don't understand why I'm getting downvoted for this question. No where can I find a tutorial on how to split the back and fourth buttons. How professional can your website be if you're restricted to placing the page links to one spot on the page? seriously...
In Laravel 5 there is a single configuration option for Eloquent models to generate pagination. So, you can use the method:
<?php echo $promotion->render(); ?>
If you want an option only with Previous and Next buttons, you need to use
$promotion = Promotions::simplePaginate(5);
Instead of
$promotion = Promotions::paginate(5);
This is driving me crazy. No matter what export I do using profile, the column "assocciated", as mentioned in various magento guides is missing. I have around 7000 products and need to export them with the parent/child relationship intact, however, after export it just shows all the products without any columns mentioning the relationship also link for only 1 image is shown even when there are more than 5 images.
I would like to see the configurable products with all the associated products (seperated by comma) OR simple products with the sku of configurable product.
Is there any option to accomplish this?
Thanks.
U can use this code
(please make filename.php under your web root
<?php
require_once 'app/Mage.php';
Mage::app();
//$parentProduct= Mage::getModel('catalog/product')->load('2862');
$parentCollection = Mage::getResourceModel('catalog/product_collection')
->addAttributeToSelect('*')
->addAttributeToFilter('type_id','configurable')
->addAttributeToFilter('status','1');
//$pid = array();
$read= Mage::getSingleton('core/resource')->getConnection('core_read');
function getAttributeValue($value){
global $read;
$query = "select value from eav_attribute_option_value where option_id = '$value'";
$customAttributeValue = $read->fetchAll($query);
return $customAttributeValue[0]['value'];
}
?>
<style>
tr td{
border:1px solid black;
}
</style>
<table>
<thead>
<tr>
<td>sku</td>
<td>simple_skus</td>
<td>type</td>
<td>class</td>
<td>silos</td>
</tr>
</thead>
<tbody>
<?php
foreach($parentCollection as $parentID){
$parentProducts = Mage::getModel('catalog/product')->load($parentID->getId());
$childProducts = Mage::getModel('catalog/product_type_configurable')
->getUsedProducts(null,$parentProducts);
?>
<?php
foreach($childProducts as $child){
?>
<tr>
<td>
<?php echo $child->getSku();?>
</td>
<td>
<?php echo " "?>
</td>
<td>
<?php echo $child->getTypeId()?>
</td>
<td>
<?php
$value = $parentProducts->getClass();
echo getAttributeValue($value);
?>
</td>
<td>
<?php
$value = $parentProducts->getSilos();
echo getAttributeValue($value);
?>
</td>
</tr>
<?php }?>
<tr>
<td>
<?php echo $parentProducts->getSku();
?>
</td>
<td>
<?php
$separation = array();
foreach($childProducts as $child){
$separation[] = $child->getSku();
}
echo implode(',',$separation);
?>
</td>
<td>
<?php echo $parentProducts->getTypeId();?>
</td>
<td>
<?php
$value = $parentProducts->getClass();
echo getAttributeValue($value);
?>
</td>
<td>
<?php
$value = $parentProducts->getSilos();
echo getAttributeValue($value);
?>
</td>
</tr>
<?php
}
?>
</tbody>
</table>
then browser your filename.php from your website
from that list you can convert html to csv
check this
http://www.convertcsv.com/html-table-to-csv.htm
hope this help
Magento provides export and import for configurable products from System > Import/Export > Dataflow - Profiles, please see the attached image how it's exporting configurable products
Main columns to take care about are type and has option as parent product will be assigned with has_option as 1 ,visibility as catalog, seacrh and it's child products which will assigned value for has_option as 0 , visibililty as Not Visible Individually and it's related attributes values like shoe_type , shoe_size and gender
-magmi option to import configurable products which will assign Associated products to parent product.Before this import one need to first import simple and configurable products.
The following code works fine, except that there is some "cleaning up" of the data that is taking place in one instance and not the other that I can't decipher.
I have a table (clientdocs) with a field 'from' that contains string data in the format:
Richard Robinson <richard#gmail.com>
In my controller, I have code that builds an array for a dropdown from this table:
// get clients
$sender_sel = array('Any Sender');
$senders = Clientdoc::orderBy('from', 'ASC')
->distinct()
->get( array('from') );
foreach($senders as $sender) {
$sender_sel[] = $sender->from;
}
I also retrieve all the data from the table and pass it to the view (along with the above array and other stuff):
return View::make('clientdocs/index')
->with('date_sel', $date_sel)
->with('sender_sel', $sender_sel)
->with('docs', Clientdoc::orderBy('date_emailed', 'ASC')->get());
Now, in my view:
I use $sender_sel as:
{{ Form::select('from', $sender_sel, '', array(
'class' => 'form-control'
)) }}
and it displays as expected:
"Richard Robinson <richard#gmail.com>"
and I also use data from the 2nd query (docs object):
<table class="table table-striped table-hover">
<tr>
<th>Date</th>
<th>From</th>
<th>Type</th>
</tr>
#foreach ($docs as $doc)
<?php $detail_url = 'clientdocs/' . $doc->id . '/edit' ; ?>
<tr>
<td>{{ $doc->from }}</td>
</tr>
#endforeach
</table>
Here's the kicker: $docs->from displays as
"Richard Robinson", without the "<richard#gmail.com>"
Any ideas why?
View source. It's still there, but < and > are special characters in HTML (as they're used in HTML tags).
Using triple brackets escapes output in Blade, so {{{ $doc->from }}} will fix it by turning it into < and >.