i am new to the programming.i have list of customer in table.i want to make the individual profile page for each customer with their database credentials.So how can i do it to make name clickable so their profile page will open (in codeigniter).this is my table....
<table>
<thead>
<tr>
<th scope="col">S/N</th>
<th scope="col">Customer Name</th>
<th scope="col">Customer Email</th>
<th scope="col">Customer Country</th>
<th scope="col">Customer City</th>
<th scope="col">Customer Address</th>
<th scope="col">Customer Contact</th>
<th scope="col">Customer Image</th>
<th scope="col">Modify</th>
</tr>
</thead>
<tbody>
<?php $i = 1;?>
<?php if($customer->num_rows()>0):?>
<?php foreach($customer->result() as $rows):?>
<tr>
<td><?php echo $i;?></td>
<td><a href="<?php base_url();?>admin/customer/profile"<?php echo $rows->customer_name;?><a></td>
<td><?php echo $rows->customer_email;?></td>
<td><?php echo $rows->customer_country;?></td>
<td><?php echo $rows->customer_city;?></td>
<td><?php echo $rows->customer_address;?></td>
<td><?php echo $rows->customer_contact;?></td>
<td><img id="img" src="<?php echo base_url();?>customer/<?php echo $rows->customer_image;?>" width="30px" height="30px"/></td>
<td>
</td>
</tr>
<?php $i++;?>
<?php endforeach;?>
<?php endif;?>
</tbody>
</table>
Related
In my database one project has many tasks. I was able to give the edit option for each record by parsing the record id when the update button is clicked. But as one project has many task now I need to parse the projectname when the button clicked and show all the tasks related to that project. Can Somebody help me?
This is the button with record
This is the code
<table class="table table-lg">
<thead >
<tr class="filters">
<th class="col-lg-1"><input type="text" class="form-control" placeholder="Project" disabled></th>
<th class="col-lg-1"><input type="text" class="form-control" placeholder="Client" disabled></th>
<th class="col-lg-1"><input type="text" class="form-control" placeholder="Task " disabled></th>
<th class="col-lg-1"><input type="text" class="form-control" placeholder="Description" disabled></th>
<th class="col-lg-2"><input type="text" class="form-control" placeholder="Create Date and Time" disabled></th>
<th class="col-lg-2"><input type="text" class="form-control" placeholder="Start Date and Time" disabled></th>
<th class="col-lg-2"><input type="text" class="form-control" placeholder="Due Date and Time" disabled></th>
<th class="col-lg-1"> Edit</th>
<th class="col-lg-1"> Delete</th>
</tr>
</thead>
<tbody>
<?php
if(isset($view_data) && is_array($view_data) && count($view_data)): $i=1;
foreach ($view_data as $key => $data) {
?>
<tr <?php if($i%2==0){echo 'class="even"';}else{echo'class="odd"';}?>>
<td><?php echo $data['projectname']; ?></td>
<td><?php echo $data['cname']; ?></td>
<td><?php echo $data['mytext']; ?></td>
<td><?php echo $data['mytext1']; ?></td>
<td><?php echo $data['mytext2']; ?></td>
<td><?php echo $data['mytext3']; ?></td>
<td><?php echo $data['mytext4']; ?></td>
<td><?php echo $data['mytext5']; ?></td>
<td><a class="btn btn-warning" role="button" href="<?php echo site_url('Task/edit_data/'. $data['id'].''); ?>"><i class="glyphicon glyphicon-pencil"></i> Edit</a></td>
<td><a type="button" class="btn btn-danger" href="<?php echo site_url();?>/Task/delete_data/<?php print($data['id']);?>">
<img src='' title="Delete" onClick="return doconfirm();" />
</a></td>
</tr>
<?php
$i++;
}
else:
?>
<tr>
<td colspan="7" align="center" >No Records Found..</td>
</tr>
<?php
endif;
?>
</tbody>
</table>
I have a for loop inserting data into my table, works well.
Problem is each loop I wish for it to start a new row, but it starts a new table. any ideas how to fix this?
<?php if (isset($records)) : foreach ($records as $row) : ?>
<div id="mobile-content">
<table class="table table-hover">
<thead>
<tr>
<th>Account Name</th>
<th>Balance</th>
<th>Start Date</th>
</tr>
</thead>
<tbody>
<tr>
<td><?php echo $row->bank_name; ?></td>
</tr>
<tr>
<td><?php echo $row->bank_balance; ?></td>
</tr>
<tr>
<td><?php echo $row->bank_start_date; ?></td>
</tr>
</tbody>
</table>
</div>
<?php endforeach; ?>
You should change the code to loop inside the table body, not in the whole table code:
<div id="mobile-content">
<table class="table table-hover">
<thead>
<tr>
<th>Account Name</th>
<th>Balance</th>
<th>Start Date</th>
</tr>
</thead>
<tbody>
<?php if (isset($records)) : foreach ($records as $row) : ?>
<tr>
<td><?php echo $row->bank_name; ?></td>
<td><?php echo $row->bank_balance; ?></td>
<td><?php echo $row->bank_start_date; ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
Note: I've also remove extra <tr> because you need one row for the three cells.
I hope that helps :D
I have a problem in viewing only a class list that I choose and add student but when I select other class it will also appear/view that I select in previous class
here I select the class that I select
Here is the class page that I select and then I add student
but when I choose another class it will also appear the student
here is my controller:
public function viewspecificclass($id)
{
if($this->session->userdata('logged_in'))
{
$this->output->set_header('Expires: Sat, 26 Jul 1997 05:00:00 GMT');
$this->output->set_header('Cache-Control: no-cache, no-store, must-revalidate, max-age=0');
$this->output->set_header('Cache-Control: post-check=0, pre-check=0', FALSE);
$this->output->set_header('Pragma: no-cache');
$session_data = $this->session->userdata('logged_in');
$data['Username'] = $session_data['Username'];
$row=$this->model_adminlogin->getonerowclass($id);
$data['r']=$row;
$data['classid'] = $id;
$this->load->view('individualviewclass',$data);
} else{
redirect('welcome', 'refresh');
}
if((!isset($session_data) || $session_data !=TRUE)) {
redirect('welcome', 'refresh');
}
}
public function addstudentnow($classid, $studentid){
$data= array(
'ClassId'=>$classid,
'Id'=> $studentid
);
$this->db->insert('enroll',$data);
$this->session->set_flashdata('category_success', 'Successfully Add!');
redirect('enrollment/viewspecificclass ');
}
here is my model:
function statusofenrollment(){
$this->db->select('*');
$this->db->from('studentinformation');
$this->db->join('statusofenrollment', 'statusofenrollment.Id = studentinformation.Id', 'left');
$query = $this->db->get();
return $query->result();
}
function studentinclasslist(){
$this->db->select('*');
$this->db->from('statusofenrollment');
$this->db->join('studentinformation', 'studentinformation.Id = statusofenrollment.Id', 'right');
$this->db->join('enroll', 'enroll.Id = studentinformation.Id', 'right');
$query = $this->db->get();
return $query->result();
}
here is the view:
<div class="z table-responsive">
<table class=" table table-striped ">
<thead>
<tr>
<th class="text-center">LRN</th>
<th class="text-center">First name</th>
<th class="text-center"> Middle name</th>
<th class="text-center">Last name</th>
<th class="text-center">Gender</th>
<th class="text-center">Status of Enrollment</th>
<th class="text-center"> </th>
</tr>
</thead>
<?php
foreach($this->model_adminlogin->studentinclasslist() as $row){
?>
<tr>
<td class="text-capitalize text-center"><?php echo $row->Idnumber ?></td>
<td class="text-capitalize text-center"><?php echo $row -> Firstname ?></td>
<td class="text-capitalize text-center"><?php echo $row->Middlename ?></td>
<td class="text-capitalize text-center"><?php echo $row->Lastname ?></td>
<td class="text-capitalize text-center"><?php echo $row->Sex ?></td>
<td class="text-capitalize text-center"><?php echo $row->Statusofenrollment ?></td>
<td class="text-capitalize text-center">
</td>
</tr>
<?php
}
?>
</table>
</div>
<div id="myModalpick" class="modal fade" role="dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title text-center">Student Status</h4>
</div>
<div class="modal-body">
<div class="z table-responsive">
<table class=" table table-striped ">
<thead>
<tr>
<th class="text-center">LRN</th>
<th class="text-center">First name</th>
<th class="text-center"> Middle name</th>
<th class="text-center">Last name</th>
<th class="text-center">Gender</th>
<th class="text-center">Status of Enrollment</th>
<th class="text-center"> </th>
</tr>
</thead>
<?php
foreach($this->model_adminlogin->statusofenrollment() as $row){
?>
<tr>
<td class="text-capitalize text-center"><?php echo $row->Idnumber ?></td>
<td class="text-capitalize text-center"><?php echo $row -> Firstname ?></td>
<td class="text-capitalize text-center"><?php echo $row->Middlename ?></td>
<td class="text-capitalize text-center"><?php echo $row->Lastname ?></td>
<td class="text-capitalize text-center"><?php echo $row->Sex ?></td>
<td class="text-capitalize text-center"><?php echo $row->Statusofenrollment ?></td>
<td class="text-capitalize text-center">
Add To Class List
</td>
</tr>
<?php
}
?>
</table>
</div>
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-default" >Ok</button>
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
</div>
</div>
</div>
because of the fact that your code is totally unorganized it makes hard to help you - but i'll give it a shot
first of all in your models Function studenClassList you've to pass an id from the specific class because other wise you'll get on any request the students of all of your classes - change your model like this
function studentinclasslist($classId){
$query = $this->db
->select('studentinformation.*')
->from('statusofenrollment')
->join('studentinformation', 'studentinformation.Id = statusofenrollment.Id', 'right')
->join('enroll', 'enroll.Id = studentinformation.Id', 'right')
->where("class.Id",$classId)
->get();
return $query->result();
}
be aware that you have to change in the where construct the actual class.Id field because i wasn't able to see where it is
and after that in your view simply pass the ID to your model function
foreach($this->model_adminlogin->studentinclasslist($classId) as $row){
but in any case i must say, in my opinion it isn't a good idea in CI to use a model in your view because the controller should pass the prepared model data to the view
In my application, i have upload image and fill some fields. These values and upload image path also to be saved in database. I don't know to how to retrieve image from folder. My code is,
The Controller part is
function getdatatableajax()
{
$this->load->library('datatables');
$this->datatables
->select("products.id as id, pathinfo, products.name as pname, price, measurement, tax_rates.name")// measurement,tax_rates.name
->from("products")
->join('tax_rates', 'tax_rates.id=products.tax_rate', 'left')
->group_by('products.id')
->add_column("Actions",
"<center>
<div class='btn-group'>
<a class=\"tip btn btn-primary btn-xs\" title='".$this->lang->line("edit_product")."' href='index.php?module=products&view=edit&id=$1'>
<i class=\"fa fa-edit\"></i></a>
<a class=\"tip btn btn-danger btn-xs\" title='".$this->lang->line("delete_product")."' href='index.php?module=products&view=delete&id=$1' onClick=\"return confirm('". $this->lang->line('alert_x_product') ."')\">
<i class=\"fa fa-trash-o\"></i></a>
</div></center>", "id")
->unset_column('id');
echo $this->datatables->generate();
}
The model part is
public function getAllProducts()
{
$q = $this->db->get('products');
if($q->num_rows() > 0) {
foreach (($q->result()) as $row) {
$data[] = $row;
}
return $data;
}
}
The View part is
<table id="fileData" cellpadding=0 cellspacing=10 class="table table-bordered table-hover table-striped">
<thead>
<tr>
<th><?php echo $this->lang->line("Image"); ?></th>
<th><?php echo $this->lang->line("name"); ?></th>
<th><?php echo $this->lang->line("price"); ?></th>
<th><?php echo $this->lang->line("Measurement"); ?></th>
<th><?php echo $this->lang->line("tax_rate"); ?></th>
<th style="width:45px;"><?php echo $this->lang->line("actions"); ?></th>
</tr>
</thead>
<tbody>
<tr>
<td colspan="7" class="dataTables_empty"><?php echo $this->lang->line('loading_data_from_server'); ?></td>
</tr>
</tbody>
<tfoot>
<tr>
<th><?php echo $this->lang->line("Image"); ?></th>
<th><?php echo $this->lang->line("name"); ?></th>
<th><?php echo $this->lang->line("price"); ?></th>
<th><?php echo $this->lang->line("Measurement"); ?></th>
<th><?php echo $this->lang->line("tax_rate"); ?></th>
<th style="width:45px;"><?php echo $this->lang->line("actions"); ?></th>
</tr>
</tfoot>
</table>
From where are add image retrieval code.?
Use This :-
<img src="<?php echo base_url('images/1.jpg'); ?>" />
Check this Post for more details
Sorry for asking this old questions, and I know that I've read before I ask here, it's can use database for adding more cart without limitation. I already try to use ci_sessions table to store session but still no luck, I only can adding 6 items maximum.
please help me, I looking for some example for this almost two days and result is nothing
EDITED
this is my view
<table id="box-table-a" summary="Employee Pay Sheet">
<thead>
<tr>
<th scope="col">Description</th>
<th scope="col">Price</th>
<th class="centered" scope="col">Options</th>
</tr>
</thead>
<tbody>
<?php foreach ($foto_produk->result() as $key => $value) {?>
<tr>
<td><?php echo $value->description;?></td>
<td><?php echo $value->price;?></td>
<td class="centered"><input type="checkbox" name="produk_foto[]" value="<?php echo $value->id;?>" /></td>
</tr>
<?php }?>
</tbody>
</table>
here's my controller code
if($this->input->post('produk_foto')){
$id_foto = $this->input->post('produk_foto');
foreach ($id_foto as $key => $value) {
$this->db->where('id', $value);
$query = $this->db->get('foto_product');
if($query->num_rows() > 0){
foreach($query->result() as $ids => $rows){
echo $rows->id.'<br />';
$data_produk = array(
'user_data'=> array(
'id' => $rows->id,
'price' => $rows->price,
'name' => $rows->description,
'qty' => $rows->aantal
)
);
$this->cart->insert($data_produk);
}
}
}
}
and this my view code
<?php if(!$this->cart->contents()):?>
<div class="alert-box warning">The regular products are empty.</div>
<div class="clearfix"></div>
<?php else:?>
<hr>
<h4>REGULAR PRODUCTS</h4>
<div class="order_detail" id="Display">
<table>
<thead>
<tr>
<th>DESCRIPTION</th>
<th>QUANTITY</th>
<th>PRICE PER ITEM(S)</th>
<th>TOTAL</th>
<th>REMOVE</th>
</tr>
</thead>
<tbody>
<?php foreach($this->cart->contents() as $rows):?>
<tr>
<td style="font-weight:bold;"><?php echo $rows['name'];?></td>
<td>
<?php echo form_open(current_url());?>
<input type="text" size="3" name="quantity" value="<?php echo $rows['qty'];?>" />
<input type="hidden" size="3" name="rowid" value="<?php echo $rows['rowid'];?>" />
<input type="submit" name="update" value="Update" />
<?php echo form_close();?>
</td>
<td><?php echo $rows['price'];?></td>
<td><?php echo $this->cart->format_number($rows['subtotal']);?></td>
<td>delete</td>
</tr>
<?php endforeach;?>
</tbody>
<tfoot>
<tr>
<td colspan="3">Total Products</td>
<td colspan="3">€ <?php echo $this->cart->format_number($this->cart->total());?></td>
</tr>
<tr>
<td colspan="3">Total Shipping</td>
<td colspan="3"></td>
</tr>
<tr>
<td colspan="3"></td>
<td colspan="3" style="padding:0;text-align:center;">
<p>TOTAL :</p>
<span class="tot">€ <?php echo $this->cart->format_number($this->cart->total());?></span>
</td>
</tr>
</tfoot>
</table>
</div>
<?php endif;?>
with this code I want to insert using checkbox with array, and I have more than 6 checkbox
thank you in advance
Ok it's solved by my self..
I don't know that in the name of product there are special characters..
and shame of me..
but thank you anyway