Jump to content

two tables problem


web_master

Recommended Posts

Hi,

 

I got a problem with two tables. There is a one with users, and the other is with logs of the users.

 

USERS table

- ID

- name

 

LOGS table

- ID

- users_ID

- log_datetime

 

I want to list this tables like this

Name 1

- log_datetime

- log_datetime

- log_datetime...

 

Name 2

- log_datetime

- log_datetime

- log_datetime...

 

Name 3

- log_datetime

- log_datetime

- log_datetime...

 

So, every names just one time, and below every log belong to that name...

 

Thanks..

 

T

Link to comment
Share on other sites

in your case it sounds like you will want to use a JOIN query..

For information on using a JOIN query, look here

 

Yes, I want to JOIN tables, thats OK, but after JOIN when I list its looks like this:

 

Name 1

- log 1

Name 1

- log 2

Name 1

- log 3

 

Name 2

- log 1

Name 2

- log 2

Name 2

- log 3 ....

Link to comment
Share on other sites

can you post the relevant query code please

 

$Querylog = mysql_query(' SELECT

p_users.p_users_id,

p_users.p_users_nick,

p_users_log.p_users_log_id,

p_users_log.p_users_log_user,

p_users_log.p_users_log_datetime

FROM

p_users

Inner Join p_users_log ON p_users.p_users_id = p_users_log.p_users_log_user

ORDER BY `p_users_log_user` ASC ');

if(!$Querylog){ echo mysql_error(); exit; }

while($request_log = mysql_fetch_array($Querylog)) {

 

}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.