Jump to content

Recommended Posts

Hello!

I have a user management system, and i am struggling with the friends section.

 

I have a DB called friends.

The structure is like this: category, friend, friend2, friend_text, friend2_text

 

What i want to do, but can't figure out, is to list all the entries, but by grouping it into category.

 

Like this:

category1

--

friend

friend

friend

 

category2

--

friend

friend

friend

 

 

If you understand? I just want to know how the SQL is going to look like.

Link to comment
https://forums.phpfreaks.com/topic/144647-solved-phpmysql-grouping-into-category/
Share on other sites

<?php

while ($row = mysql_fetch_assoc($result)) {
    if ($last_cat != $row['category']) {
           echo "<br />" . $row['category'] . "<br />--<br />";
           $last_cat = $row['category'];
    }
    
    echo $row['friend'] . "<br />";
}
?>

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.