I have a problem regarding the width in a bootstrap table, it goes way to the side of the website, screenshot under
http://i.stack.imgur.com/FLZwD.png
EDIT:
<div class="container">
<h1>URL Stats <small>Shortened URL's with their full stats.</small></h1>
<table class="table table-striped table-bordered" id="statstable">
<thead>
<tr>
<th>URL ID</th><th>URL Unique ID</th><th>Short Link</th><th>Redirect Link</th><th>Date Created</th><th>End Date</th><th>Days Left</th>
</tr>
</thead>
<hr>
<tbody>
<?php
$result = mysql_query("SELECT * FROM links WHERE shortlinkid='$shortlinkid'") or die(mysql_error());
while ($row = mysql_fetch_array($result)) {
$now = date("Y-m-d");
$start = $row['date_created'];
$end = $row['end_date'];
$diff = (strtotime($end) - strtotime($now))/24/3600;
echo "<tr>";
echo "<td>".$row['id']."</td>";
echo "<td>".$row['shortlinkid']."</td>";
echo "<td><a href='http://".$row['fullurl']."'>".$row['fullurl']."</a></td>";
echo "<td><a href='".$row['redirect']."'>".$row['redirect']."</a></td>";
echo "<td>".$row['date_created']."</td>";
echo "<td>".$row['end_date']."</td>";
echo "<td>".$diff."</td>";
echo "</tr>";
}
?>
</tbody>
</table>
</div>
This has not been an issue before, and it works fine in other browsers other than Chrome
Change this:
echo "<td><a href='http://".$row['fullurl']."'>".$row['fullurl']."</a></td>";
echo "<td><a href='".$row['redirect']."'>".$row['redirect']."</a></td>";
To this:
echo "<td><a href='http://".$row['fullurl']."'>Full URL</a></td>";
echo "<td><a href='".$row['redirect']."'>Redirect</a></td>";
Instead of echoing the entire URL for the link label, use some descriptive text to click on. Change labels as needed.
Related
I have some data in mysql database, some of them are have same value.
I already show it in my program:
But it is possible to make rowspan like this?
this is my code.
<tbody class="table-bordered">
<?php $i = 1;
foreach ($altrankq1 as $alt) : ?>
<tr>
<td class="text-center"><?= $i; ?></td>
<td class="text-center"><?= $alt['kode_alternatif']; ?></td>
<td class="text-center"><?= round(($alt['nilai_Q1']), 4); ?></td>
</tr>
<?php $i++;
endforeach; ?>
</tbody>
maybe u can check the 'nilai_q1' like this(?)
<tbody class="table-bordered">
<?php $i = 1; $a = null;
foreach ($altrankq1 as $alt) : ?>
<tr>
<td class="text-center">
<?php
$b = round(($alt['nilai_Q1']), 4);
if($a === $b) {
$i = $i - 1;
echo $i;
} else {
echo $i;
}
$a = $b;
?>
</td>
<td class="text-center"><?= $alt['kode_alternatif']; ?></td>
<td class="text-center"><?= round(($alt['nilai_Q1']), 4); ?></td>
</tr>
<?php $i++;
endforeach; ?>
</tbody>
nb: not tested yet and isnt rowspan
or trying with jquery, i found this answer in stackoverflow rowspan-table-if-values-is-the-same-in-php
I retrieve the data from the database and tried to implement them in the table, but now I don't know how to arrange them in the table. My view is:
<?php include('inc/header.php');?>
<div class="main">
<table>
<thead>
<tr>ID:</tr>
<th>Name:</th>
</thead>
<tbody>
<tr>
<?php foreach ($view as $row) :?>
<?php $i = 1;?>
<?php echo "<td>".$row->audio."</td>";?>
<?php echo $i++;?>
<?php endforeach;?>
</tr>
</tbody>
</table>
</div>
<?php include('inc/footer.php');?>
I just want to make the place id increase from one to the as many records and arrange them into one table.
Your foreach loop should be like this
<tbody>
<?php
$i = 1;
foreach ($view as $row)
{
echo "<tr>";
echo "<td>".$i."</td>";
echo "<td>".$row->audio."</td>";
$i++;
echo "</tr>";
}
?>
</tbody>
And <thead> should be
<thead>
<tr>
<th>ID:</th>
<th>Name:</th>
</tr>
</thead>
Try This Code
<?php
$i=1;
foreach ($view as $row)
{
?>
<tr>
<td><?php echo $i; ?></td>
<td><?php echo $row->audio;?></td>
</tr>
<?php
$i++;
} ?>
You can try this
<?php $i = 1;?>
<?php foreach ($view as $row) :?>
<tr>
<?php echo "<td>".$i++."</td>";?>
<?php echo "<td>".$row->audio."</td>";?>
</tr>
<?php endforeach;?>
Try the following code:
<?php
$i=0;//place the initial value outside the loop
foreach ($view as $row)
{
$i++;//increment the value
?>
<tr>
<td><?php echo $i;//display the value ?></td>
<td><?php echo $row->audio;?></td>
</tr>
<?php
} ?>
I currently use a code to display some content in my Magento shop.
But now I want to split the loaded content based on even/odd into two different divs.
My current code is displayed below.
How can I split the code based on even/odd so that I get to <div class="block-specs">.
I want a div <div class="block-specs odd"> and <div class="block-specs even">
How can I achieve that?
Current code:
<?php if($_additionalgroup = $this->getAdditionalData()): ?>
<section id="additional">
<div class="box-collateral box-additional">
<h2><?php echo $this->__('Additional Information') ?></h2>
<?php $i=0; foreach ($_additionalgroup as $_additional): $i++; ?>
<div class="block-specs-<?php echo $i?>">
<h3 class="specs-<?php echo $i?>"><?php echo $this->__( $_additional['title'] )?></h3>
<table class="data-table specs-<?php echo $i?>" id="product-attribute-specs-table-<?php echo $i?>">
<col width="25%" />
<col />
<tbody>
<?php foreach ($_additional['items'] as $_data): ?>
<?php $_attribute = $_product->getResource()->getAttribute($_data['code']);
if (!is_null($_product->getData($_attribute->getAttributeCode())) && ((string)$_attribute->getFrontend()->getValue($_product) != '')) { ?>
<tr>
<th class="label"><?php echo $this->htmlEscape($this->__($_data['label'])) ?></th>
<td class="data"><?php echo $_helper->productAttribute($_product, $_data['value'], $_data['code']) ?></td>
</tr>
<?php } ?>
<?php endforeach; ?>
</tbody>
</table>
</div>
<script type="text/javascript">decorateTable('product-attribute-specs-table-<?php echo $i?>')</script>
<?php endforeach; ?>
</div>
</section>
<?php endif;?>
Check if the index is evenly divisable by 2 with '%' this returns the remainder after dividing (0 if even).
<?php foreach ($_additionalgroup as $i => $_additional):
// if evenly divisable by 2, it is even
$oddEven =($i % 2) ? 'odd':'even';
?>
<div class="block-specs-<?php echo $oddEven; ?>">
In the following HTML table snippet, I will like to add footnotes (or simple comments) for columns "stat 1", "stat 2" and "stat 3" to explain each of the stats in more detail. Preferably, want the comments/details to appear right below the table with each comment correctly referring to the right column. Any suggestion on how to achieve this? Thanks.
if(!empty($output))
{
echo '<table cellpadding="0" cellspacing="0" class="imagetable">';
echo '<caption>Table 1</caption>';
echo '<tr><th>Date</th><th>Stat 1</th><th>Stat 2</th><th>Stat 3</th><th></tr>';
foreach ($output as $result)
{
$temp = explode(" ",$result);
echo '<tr>';
for($i=0;$i<count($temp);$i++){
echo '<td>',$temp[$i],'</td>';
}
echo '</tr>';
}
echo '</table><br />';
}
You could use tfoot (http://www.w3schools.com/tags/tag_tfoot.asp)
if(!empty($output))
{
echo '<table cellpadding="0" cellspacing="0" class="imagetable">';
echo '<caption>Table 1</caption>';
echo '<thead><tr><th>Date</th><th>Stat 1</th><th>Stat 2</th><th>Stat 3</th></tr></thead>';
echo '<tfoot><tr><td> </td><td>*note 1</td><td>*note 2</td><td>*note 3</td></tr></tfoot>';
foreach ($output as $result)
{
$temp = explode(" ",$result);
echo '<tr>';
for($i=0;$i<count($temp);$i++){
echo '<td>',$temp[$i],'</td>';
}
echo '</tr>';
}
echo '</table><br />';
}
I have a script that displays information of these fields- batchname, class, batchinstructor from the table "batch". But I want to display dynamically generated serial number on the left side when I show the data. For example:
Serial Number BatchName Class Batch Instructor
1. Solar Class Five John
2. Lunar Class six Bon Jovi
I have tried a lot but its not working. Would you please kindly help me to solve this? Please note that these serial number are not from database.
Here's my Controller:
<?php
class Batchlist extends CI_Controller{
function index(){
$this->load->library('pagination');
$config['base_url'] = base_url().'batchlist/index';
$config['total_rows'] = $this->db->get('batch')->num_rows();
$config['per_page'] = 20;
$config['num_links'] = 20;
$config['full_tag_open'] = '<div class="pagination" align="center">';
$config['full_tag_close'] = '</div>';
$this->pagination->initialize($config);
$this->load->model('mod_batchlist');
$data['records']= $this->mod_batchlist->batch_list($config['per_page'],$this->uri->segment(3));
$data['main_content']='view_batchlist';
$this->load->view('includes/template',$data);
}
}
?>
Here's my Model:
function batch_list($perPage,$uri) {
$this->db->select('*');
$this->db->from('batch');
$this->db->join('teacher', 'batch.batchinstructor = teacher.teacherid');
$this->db->order_by('batchid','DESC');
$getData = $this->db->get('', $perPage, $uri);
if($getData->num_rows() > 0)
return $getData->result_array();
else
return null;
}
Here's my View
<h1>Batch List </h1>
<?php if(count($records) > 0) { ?>
<table id="table1" class="gtable sortable">
<thead>
<tr>
<th>Batch Name</th>
<th>Class</th>
<th>Batch Instructor</th>
<th>Edit/Delete</th>
</tr>
</thead>
<tbody>
<?php foreach ($records as $row){ ?>
<tr>
<td><?php echo $row['batchname'];?></td>
<td><?php echo $row['class'];?></td>
<td><?php echo $row['teachername'];?></td>
<td> <img src="<?php echo base_url(); ?>support/images/icons/edit.png" alt="Edit" />
<img src="<?php echo base_url(); ?>support/images/icons/cross.png" alt="Delete" />
</td>
</tr>
<?php } ?>
</tbody>
</table>
<?php } ?>
<div class="tablefooter clearfix">
<div class="pagination">
<?php echo $this->pagination->create_links(); ?>
</div>
</div>
Maybe I misunderstood, but...what about a simple counter?? (after you ordered your records in SQL).
You need to pass to the view the number of items per page (in this snippet: $per_page), then you retrieve the current page from the URI ($this->uri->segment(n)).
At page 1, counter starts from (20*0)+1, i.e. 1. At page 2, starts from (1*20)+1 ie 21, at page 3 from (2*20)+1 ie 41 and so on...
<?php
$cur_page = $this->uri->segment(n) ? intval($this->uri->segment(n)) : 1;
$i = (($cur_page-1) * $per_page) +1;
foreach ($records as $row) :
?>
<tr>
<td><?php echo $i;?>.</td>
<td><?php echo $row['batchname'];?></td>
<td><?php echo $row['class'];?></td>
<td><?php echo $row['teachername'];?></td>
<td> <img src="<?php echo base_url(); ?>support/images/icons/edit.png" alt="Edit" /><img src="<?php echo base_url();?>support/images/icons/cross.png" alt="Delete" />
</td>
</tr>
<?php
++$i;
endforeach;
?>
You can place the counter wherever you want, I added a column for simplicity but if you want it somewhere else just place the counter there.
You said the serial numbers are not from the database. Where are they from then? If you want the database to generate them you can create a column named id and set it as the primary key and have it auto increment.