[eluser]Unknown[/eluser]
hi, i'm new to php and this is the first framework i am trying to be familiar with..
currently i am creating a page that will fetch multiple data from mysql..
my question is how can i get the data displayed horizontally..
below is my table structure and how i want it to be viewed..
thanks guys...
===========================
table_login_details
field_useid
field_name
field_login
field_logout
field_late
field_date
here is my data...
userid | name | login | logout | late | date
1 | user1 | 8:00 | 16:40 | 0 | 2011-10-01
2 | user2 | 9:00 | 14:00 | 0 | 2011-10-01
3 | user3 | 8:30 | 15:00 | 0 | 2011-10-01
4 | user4 | 8:20 | 12:10 | 0 | 2011-10-01
5 | user5 | 8:00 | 14:00 | 0 | 2011-10-01
6 | user6 | 8:45 | 16:00 | 0 | 2011-10-01
1 | user1 | 8:00 | 16:40 | 0 | 2011-10-02
2 | user2 | 9:00 | 14:00 | 0 | 2011-10-02
3 | user3 | 8:30 | 15:00 | 0 | 2011-10-02
4 | user4 | 8:20 | 12:10 | 0 | 2011-10-02
5 | user5 | 8:00 | 14:00 | 0 | 2011-10-02
6 | user6 | 8:45 | 16:00 | 0 | 2011-10-02
1 | user1 | 8:00 | 16:40 | 0 | 2011-10-03
2 | user2 | 9:00 | 14:00 | 0 | 2011-10-03
3 | user3 | 8:30 | 15:00 | 0 | 2011-10-03
4 | user4 | 8:20 | 12:10 | 0 | 2011-10-03
5 | user5 | 8:00 | 14:00 | 0 | 2011-10-03
6 | user6 | 8:45 | 16:00 | 0 | 2011-10-03
1 | user1 | 8:00 | 16:40 | 0 | 2011-10-04
2 | user2 | 9:00 | 14:00 | 0 | 2011-10-04
3 | user3 | 8:30 | 15:00 | 0 | 2011-10-04
4 | user4 | 8:20 | 12:10 | 0 | 2011-10-04
5 | user5 | 8:00 | 14:00 | 0 | 2011-10-04
6 | user6 | 8:45 | 16:00 | 0 | 2011-10-04
===========================
here it should look like ( in table or divs )
_________________ ________________ ________________ ________________
| date1 | | date2 | | date3 | | date4 |
userid | name | login | logout | late | | login | logout | late | | login | logout | late | | login | logout | late |
1 | user1 | 8:00 | 16:40 | 0 | | 8:00 | 16:40 | 0 | | 8:00 | 16:40 | 0 |
2 | user2 | 9:00 | 14:00 | 0 | | 9:00 | 14:00 | 0 | | 9:00 | 14:00 | 0 |
3 | user3 | 8:30 | 15:00 | 0 | | 8:30 | 15:00 | 0 | | 8:30 | 15:00 | 0 |
4 | user4 | 8:20 | 12:10 | 0 | | 8:20 | 12:10 | 0 | | 8:20 | 12:10 | 0 |
5 | user5 | 8:00 | 14:00 | 0 | | 8:00 | 14:00 | 0 | | 8:00 | 14:00 | 0 |
6 | user6 | 8:45 | 16:00 | 0 | | 8:45 | 16:00 | 0 | | 8:45 | 16:00 | 0 |
===========================
my controller
public function display_data()
{
$data['start_month'] = $start_month;
$data['end_month'] = $end_month;
$data['query'] = $this->attendance_model->get_selected_date($start_month,$end_month);
$this->load->view('display_data',$data);
}
===========================
my model
function get_selected_date($start_month,$end_month)
{
$this->db->select('*');
$this->db->from('login_details');
$this->db->where('date >= ' . "'" . $start_month . "'");
$this->db->where('date <= ' . "'" . $end_month . "'");
$this->db->group_by('user_id');
$query = $this->db->get();
if($query->num_rows() >= 1)
{
return $query->result();
}
else
{
return false;
}
}
===========================
my view
<table align="center">
<tr>
<td> </td>
<td> </td>
<td colspan="3"><div align="center"><?php echo "$start_month" ?></div></td>
</tr>
<tr>
<td>#</td>
<td>Name</td>
<td><div align="center"> IN </div></td>
<td><div align="center">OUT</div></td>
<td><div align="center">LATE</div></td>
</tr>
<?php
$rowclass=0;
$ctr = 1;
if($query):
foreach($query as $row):
?>
<?php
echo "<tr class=\"row$rowclass\">";
echo "<td>$ctr</td>";
echo "<td>$row->name</td>";
echo "<td>$row->login</td>";
echo "<td>$row->logoff</td>";
echo "<td><font color=\"red\">$row->late</font></td>";
echo "</tr>";
$rowclass = 1 - $rowclass;
$ctr++;
?>
<?php endforeach; else: ?>
</table>
<h1>no entry yet!</h1>
<?php endif; ?>