I want to display the data per user.
But it displays all the data per table and per users.
So what I am trying to achieve is display all the data on the table for that user
here is my code
<?php foreach ($employee as $emp) { ?>
<table id="employee-content">
<h3 class="color-orange"><?php echo $emp['members']['username']; ?></h3>
<tr>
<td><p class="personal-management-content"><?php echo $emp['posts']['title']; ?></p></td>
<td><p class="personal-management-content padding-left50" class="padding-left50"><?php echo $emp['posts']['title']; ?></p></td>
<td><p class="personal-management-content padding-left50" class="padding-left50"><?php echo $emp['posts']['deadline']; ?></p></td>
</tr>
<?php } ?>'
here is the sql query for $employee
* on controller
public function employee_management() {
$posts = $this->Post->getPostByMember();
$this->set("employee", $posts);
}
* on model
public function getPostByMember() {
$post = "SELECT username, content, deadline, title FROM members INNER JOIN posts ON posts.member_id=members.id";
// debug($user);
$con = $this->getDataSource();
$get = $con->fetchAll($post);
// debug($get);
return $get;
}
and the print_r $employee
Array (
[0] => Array (
[members] => Array (
[username] => admin )
[posts] => Array (
[content] => asdsadsad
[deadline] => 2012-06-01
[title] => sad ) )
[1] => Array (
[members] => Array (
[username] => admin )
[posts] => Array (
[content] => asd
[deadline] => 2012-06-20
[title] => sad ) )
[2] => Array (
[members] => Array (
[username] => admin )
[posts] => Array (
[content] => dasdw2
[deadline] => 2012-06-19
[title] => sdas ) )
[3] => Array (
[members] => Array (
[username] => guest )
[posts] => Array (
[content] => s
[deadline] => 2012-06-08
[title] => wara ) )
the output is
sample screen shot
http://i46.tinypic.com/209n56s.jpg
so what I want to achieve is
for example the user “admin” all his titles, descriptions, deadlines will show on the single box or the .
And so goes to the other users.
please help thanks in advance
So… It looks like your database results are currently structured like this:
etc. And you want your display to look like:
It seems to me that the easiest way to achieve what you want is to create a new array from the results of your SELECT.
This is of course untested, because I don’t have your data. Depending on the structure of your database, you might be able to do this with less PHP by making a different SQL query that could be parsed more easily.