I want to sort the content in view by selecting from a drop-down list.
Sorting is possible to do in table element by
<tr>
<th><?= $this->Paginator->sort('category_id') ?></th>
<th><?= $this->Paginator->sort('subcategory_id') ?></th>
<th><?= $this->Paginator->sort('product_code') ?></th>
</tr>
But I want to have a drop-down select list. And on selecting option from list the data will be sorted.
<select>
<option><?= $this->Paginator->sort('category_id') ?></option>
<option><?= $this->Paginator->sort('subcategory_id') ?></option>
<option><?= $this->Paginator->sort('product_code') ?></option>
</select>
Related
I need to show one row per page.
this my contoller class code
public function showcontent($id)
{
$story=storybook::find($id);
$content=storycontent::where('titleid', $story['id'])->paginate(1);
//return $content;
return view('storyBook/viewStory',compact('story','content'));
}
this my view class code
#foreach($content as $content)
<?php $a=null; ?>
<?php $b=null; ?>
<?php $a=$content->file1; ?>
<?php $b=$content->file2; ?>
<table style="height: 330px;width: 680px;margin-top: 120px;margin-left: 50px">
<tr>
<td style="width: 340px"><img src="/{{$a}}" alt="Mountain View" style="width:330px;height:300px;"></td>
<td style="width: 340px"><img src="/{{$b}}" alt="Mountain View" style="width:330px;height:300px;"></td>
</tr>
</table>
<br>
#endforeach
In here i get only 1st row, rest of the rows not visible..
I do not know how to add pagination.
#foreach($content as $content)
So first of all change the naming of vars for example:
#foreach($content as $entry)
<table style="height: 330px;width: 680px;margin-top: 120px;margin-left: 50px">
<tr>
<td style="width: 340px"><img src="/{{$entry->file1}}" alt="Mountain View" style="width:330px;height:300px;"></td>
<td style="width: 340px"><img src="/{{$entry->file2}}" alt="Mountain View" style="width:330px;height:300px;"></td>
</tr>
</table>
<br>
#endforeach
$content->links()
As you can see I've added $content->links() after foreach loop. This is the method of Paginator that print out the pagination navigation.
I want to show my search output in a table using Codeigniter. Suppose if user wants to search all the volunteers of his location then the result should be shown in a table containing volunteer name,conatct no etc. Any kind of help will be realy appreciable.
You can use the CI active record class:
http://www.codeigniter.com/userguide2/database/active_record.html#select
<table>
<tr>
<th>Name</th>
<th>contact</th>
</tr>
<?php
$query = $this->db->get_where('mytable', array('feild_to_search' => 'search_query'));
foreach ($query->result() as $row)
{
?>
<tr>
<td><?php echo $row->name ?></td>
<td><?php echo $row->contact ?></td>
</tr>
<?php
}
?>
</table>
:)
we can see "Additional information " tab in magento product view page.
there we can list all attributes.
I want to display some contents under "Additional information " tab....
means
Main information
attribute label 1 : attribute value
Sub - information
attribute label 2 : atribute value.
please let me know if you need any clarifications.
thanks in advance.
As answered on Magento SE:
You could customize the template
catalog/product/view/attributes.phtml. Copy it to your theme from
base/default if it isn't there yet and include what you need.
For better maintainability, I'd recommend to just add
$this->getChildHtml('my_child_alias') to the template and define
child blocks in the layout (i.e. layout/local.xml of your theme:
<reference name="product.attributes">
<block type="core/template" name="my.custom.product.block" as="my_child_alias" template="my/custom/template.phtml" />
</reference>
Judging by the additional information from your comments here, you probably don't want to create child blocks, instead you'll have to add code within the foreach loop.
Original
<?php foreach ($_additional as $_data): ?>
<tr>
<th class="label"><?php echo $this->escapeHtml($this->__($_data['label'])) ?></th>
<td class="data"><?php echo $_helper->productAttribute($_product, $_data['value'], $_data['code']) ?></td>
</tr>
<?php endforeach; ?>
Changed (example)
<?php foreach ($_additional as $_data): ?>
<?php if ($_data['code'] == 'attribute_1'): ?>
<tr><th colspan="2"><?php echo $this->__('Main Information') ?></th></tr>
<?php elseif ($_data['code'] == 'attribute_2'): ?>
<tr><th colspan="2"><?php echo $this->__('Sub Information') ?></th></tr>
<?php endif; ?>
<tr>
<th class="label"><?php echo $this->escapeHtml($this->__($_data['label'])) ?></th>
<td class="data"><?php echo $_helper->productAttribute($_product, $_data['value'], $_data['code']) ?></td>
</tr>
<?php endforeach; ?>
where attribute_1 and attribute_2 are the codes of the first attributes of each group.
Modify File : catalog\product\view\attributes.phtml.
Replace <th></th> by this code.
<th class="label">
<?php if(array_key_exists('size',$_additional) && array_key_exists('color',$_additional) ){
if($_data['code'] == 'size'){
echo " Main features : ";
}
} ?>
<?php echo $this->escapeHtml($this->__($_data['label'])) ?>
</th>
Apply this code and check out put.
I have a view that I'm populating with results from my db in a table
I'm doing it like this:
<table>
<tr>
myHeader
</tr>
<?php
if(isset($records)){
foreach($records as $row){
echo "<tr>";
echo $row->name;
echo "</tr>";
}
}
?>
</table>
The problem is that it isn't populating my table correctly. It populates everything outside the table.
Output
<div class="grid-50">
MyHeader
user1user2user3user4
<table>
<tbody>
<tr></tr>
</tbody>
<tbody>
<tr></tr>
<tr></tr>
<tr></tr>
<tr></tr>
</tbody>
</table>
</div>
Why isn't it outputting the name of the user in a tr inside the table? And why are there two tbody being produced?
I think this will work for you :-
myHeader
<?php
if(isset($records)){
foreach($records as $row){
echo "<tr><td>";
echo $row->name;
echo "</td></tr>";
}
}
?>
</table>
You should put the content in <td> elements.
<tr>
<td>myHeader</td>
</tr>
and
echo "<tr>\n<td>";
echo $row->name;
echo "</td>\n</tr>";
Edit: and the browser does rearrange the bad content outside of any tr in the DOM, that's right, because it doesn't know what to do with the content otherwise. However, I wouldn't know why there are two tbody elements being created. No clue how that could happen.
Change:
foreach($records as $row){
echo "<tr><td>";
echo $row->name;
echo "</td></tr>";
}
I have a problem in cakephp
controller
$due = $this->Issue->find('all' , array('conditions' => array ('Issue.user_id'=>6)));
$this->set('due',$due);
$id = $due['0']['Issue']['book_id'];
$b = $this->Bookmaster->find('first' , array ('conditions' => array ('Bookmaster.id' => $bookid)));
$book = $this->Book->find('all',array('conditions' => array ('Book.id' =>$id)));
$bookid = $book['0']['Book']['bookmaster_id'];
Ctp contain
<h1> ISSUED BOOK DETAILS </h1>
<table width="200" border="2" bordercolor="#009933">
<tr>
<td> BOOK ID </td>
<td> TITLE </td>
<td> AUTHOR </td>
<td> EDITION </td>
<td>ISSUED ON </td>
<td> DUE DATE </td>
<td> POTENTIAL FINE</td>
</tr>
<?php foreach ($due as $data ) { ?> <tr>
<td> <?php echo $data['Issue']['book_id']; ?> </td>
<td> <?php echo $b ['Bookmaster']['title'] ;?></td>
<td> <?php echo $b['Bookmaster']['author'];?></td>
<td> <?php echo $b ['Bookmaster']['edition'];?> </td>
<td> <?php echo $data['Issue']['issue_date_time']; ?> </td>
<td> <?php echo $data['Issue']['due_date']; ?> </td>
<td> <?php echo $out['Fine']['fineamount'];?> </td>
</tr> <?php }?>
</table>
My problem is how can I manipulate with this with for loop.
My loop is not iterating for bookmaster.. so how can I do that..
How can i increment the value of bookid
The problem is you are looping on $due, and the $b data is a key valued array (i.e. $b[0]['bd'], $b[1]['bd'], $b[2]['bd'], etc.) Therefore, the key (or the index) for the array you are searching for will not ever be aligned with the $due loop.
A better solution is to write a join so each record contains the information you require and the loop will be able to display the data you require. More requirements / information is required on your part to enable anyone here to offer a suggestion.