Page 1 of 1

Displaying each user group data in one block

Posted: Sun Feb 07, 2010 2:59 pm
by webware
Hello To All!
I have a problem, let me explain please.
the user join a group one user may join multiple group.
on joining group he give detail and pic etc.

Now we have to display the data when a user select a group from drop down menu.

I want to display each user group data in separate block, its ok, working
But the problem i can't solve if one user post data on one group multiple time,
its also displaying in different block as i want to post that data in one block.
:?
as we also add a comment system in later.

Any alternate and professional suggestion are welcome.

waiting for replay.

Re: Displaying each user group data in one block

Posted: Mon Feb 08, 2010 11:15 am
by JakeJ
I get the impression you are storing user data more than once.

When user is created, they should get a specific id. You should have a separate table for which groups a user belongs. This would be a table for many-to-many relationships.

For example:

Table: users
id
name

Table: groups
id
group

Table: multigroups
user_id //id field from users table.
group_id //id field from groups table

Since each user can only join a group once, the two fields together for a primary key that will always be unique and you can easily query that table to find out who belongs to what groups.

Re: Displaying each user group data in one block

Posted: Mon Feb 08, 2010 1:19 pm
by webware
Its all i did before but now i want to display the data problem is here.
As i display data on bases of group, if a user post multi time data on one group i want to dispay it in one block, the array also have correct data.
the code is

Code: Select all

 
<?php 
$group_detail = group_join_by_fame($groupid);
 
for($i=0; $i < count($group_detail); $i++)   { ?>
                
            <tr>
              <td>
              <table width="100%" border="1" cellpadding="2" cellspacing="2" style="border-style:dashed;" class="group1"/>
              <tr>
              <td width="70%" align="left"> <?php  echo $group_detail[$i]['group_detail'];  ?>  </td> 
              <td width="30%" align="right"> <?php   ?> Here will pe Pic  </td> 
              </tr>
 
              <tr>
              <td rowspan="rowspan" align="left">Posted By </td> 
              </tr>
              <tr>
              <td rowspan="rowspan" align="left">Comments </td> 
              </tr>
              <tr>
              <td rowspan="rowspan" align="left">Comments By </td> 
              </tr>
              </table>
              </td>
            </tr>
            <?php
             }
               ?>
          </table>
 
 

Re: Displaying each user group data in one block

Posted: Mon Feb 08, 2010 3:36 pm
by JakeJ
That doesn't show you query so it's still hard to say what exactly you need to do but I think the best thing is to count the number of rows belong to one use and if so, send them though a loop to echo those records and then move on to the next one.