Monday, February 9, 2015
Thursday, February 5, 2015
php codeigniter html pivot table example
IN CONTROLLER
<?php
if (!defined('BASEPATH'))
exit('No direct script access allowed');
class home extends HO_Site {
public function __construct() {
parent::__construct();
}
public function index() {
$this->load->model('article_model');
$where = array();
$where['limit'] = 5;
$where['offset'] = 0;
$model = $this->article_model->get_list($where, null, array('id,title,createddate'));
$this->view(array('data' => $model));
}
}
IN VIEW
<?php
header('Content-Type: text/html; charset=utf-8');
echo 'processing...<br>';
print_r($data);
?>
<table style="border:1px solid #000;padding:5px;">
<thead>
<tr>
<?php
echo '<th>Талбар:</th>';
for ($i = 0; $i < count($data); $i++) {
echo '<th>Хэрэглэгч-' . $i . '</th>';
}
?>
</tr>
</thead>
<tbody>
<?php
$fieldNames = array_keys($data[0]);
for ($i = 0; $i < count($fieldNames); $i++) {
echo '<tr>';
for ($j = 0; $j < count($data); $j++) {
$item = $data[$j];
if ($j == 0) {
echo '<th>' . $fieldNames[$i] . '</th>';
}
echo '<td>' . $item[$fieldNames[$i]] . '</td>';
}
echo '</tr>';
}
?>
</tbody>
</table>
RESULT
<?php
if (!defined('BASEPATH'))
exit('No direct script access allowed');
class home extends HO_Site {
public function __construct() {
parent::__construct();
}
public function index() {
$this->load->model('article_model');
$where = array();
$where['limit'] = 5;
$where['offset'] = 0;
$model = $this->article_model->get_list($where, null, array('id,title,createddate'));
$this->view(array('data' => $model));
}
}
IN VIEW
<?php
header('Content-Type: text/html; charset=utf-8');
echo 'processing...<br>';
print_r($data);
?>
<table style="border:1px solid #000;padding:5px;">
<thead>
<tr>
<?php
echo '<th>Талбар:</th>';
for ($i = 0; $i < count($data); $i++) {
echo '<th>Хэрэглэгч-' . $i . '</th>';
}
?>
</tr>
</thead>
<tbody>
<?php
$fieldNames = array_keys($data[0]);
for ($i = 0; $i < count($fieldNames); $i++) {
echo '<tr>';
for ($j = 0; $j < count($data); $j++) {
$item = $data[$j];
if ($j == 0) {
echo '<th>' . $fieldNames[$i] . '</th>';
}
echo '<td>' . $item[$fieldNames[$i]] . '</td>';
}
echo '</tr>';
}
?>
</tbody>
</table>
RESULT
Wednesday, February 4, 2015
android application exit with Activity.finish() when back pressed
@Override
public void onBackPressed() {
new AlertDialog.Builder(this)
.setMessage(R.string.system_exit_confirm_message)
.setCancelable(false)
.setPositiveButton(R.string.btn_yes, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
finish();
}
})
.setNegativeButton(R.string.btn_no, null)
.show();
}
public void onBackPressed() {
new AlertDialog.Builder(this)
.setMessage(R.string.system_exit_confirm_message)
.setCancelable(false)
.setPositiveButton(R.string.btn_yes, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
finish();
}
})
.setNegativeButton(R.string.btn_no, null)
.show();
}
Subscribe to:
Posts (Atom)
Environment Variables
may be? – R.J Mar 21 '13 at 7:28