1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Showing results of mysql query

Discussion in 'Web Design & Development' started by DrP, Feb 12, 2007.

Thread Status:
Not open for further replies.
  1. DrP

    DrP Thread Starter

    Joined:
    Jul 23, 2005
    Messages:
    739
    Hi,

    I have 2 tables joined like so:

    $result = mysql_query("SELECT * FROM users LEFT JOIN calendar ON users_username = cal_username") or die(mysql_error());

    The users table is basically a list of usernames while the calendar table has lots of dates in it (several per user).

    while ($row = mysql_fetch_array($result)) {
    extract($row);
    echo "<h2>" . $users_firstname . " " . $users_surname . "</h2>"\n;
    }

    ...will give me a heading for each row and the heading will be the user's names. Now, I then want, under each heading, the list of dates. How do I do this without a second query? Basically, I want to display all the rows but I only want to show the user's names on the first row.

    Any ideas? I've looked into Group By, which didn't seem to work, but would the Distinct function work?
    Thanks,
     
  2. DrP

    DrP Thread Starter

    Joined:
    Jul 23, 2005
    Messages:
    739
    Ok, never mind! I've just done it using a separate query for each user.
     
  3. MMJ

    MMJ Guest

    Joined:
    Oct 15, 2006
    Messages:
    3,625
    Wanna mark this solved? :)
     
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Similar Threads - Showing results mysql
  1. AltaMethod
    Replies:
    5
    Views:
    321
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/543525

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice