My database
This my database “journal”
I have got the result:
Records
My problem is I have displayed the voucher number and date into only one time, it is repeated on my result.
How to display as one.
My controller code:
public function Journal_Print(){
$data['startdate'] =$this->input->post('SDate');
$data['enddate'] = $this->input->post('EDate');
$PName = $this->input->post('TName');
$startdate = $this->input->post('SDate');
$enddate = $this->input->post('EDate');
$date = str_replace('/', '-', $startdate);
$newDate = date("Y-m-d", strtotime($date));
$date2 = str_replace('/', '-', $enddate);
$newDate2 = date("Y-m-d", strtotime($date2));
$data['startdate'] = $startdate;
$data['enddate'] = $enddate;
$this->db->where('Date >=', $newDate);
$this->db->where('Date <=', $newDate2);
$query = $this->db->get('journal');
$data['PName']=$query->result_array();
// print_r($data);
$this->load->view('BookKeeping/Journal_Print', $data, FALSE);
}
My view page code:
<?php foreach ($PName as $row): ?>
<tr>
<td><?php echo date('d/m/Y', strtotime($row['Date']));?></td>
<td>
<?php echo $row['Vno'];?></td>
<td><?php echo $row['Parti'];?></td>
<td class="price"><?php echo $row['Debit'];?></td>
<td class="price1"><?php echo $row['Credit'];?></td>
</tr>
<?php endforeach ?>
How to avoid this problem
2
Answers
This Controller Code
My Answer Image enter image description here
First, get unique
Date
andVno
from DBNow, use these to get all the records from DB