its for showing a users folders. (for private messages)
how can i select one of each folder name because i know that there will be more than 1 folder name that is the same.
i have a mysql column called folder and there is a folder name in each row.

i want to display to the user his/her available folders BUT NOT REPEAT
how do i do that ?

i already know if i user SELECT folder FROM table then ill get them all how do i make it so i only get one of each name?

I am abit confused for what you are asking but I think what you are looking for are:

SELECT * FROM TABLE DISTINCT

The DISTINCT value dosent allow repeat answers, which may solve your problem.
Let me know how it goes.

Thanks, Regards X

its for showing a users folders. (for private messages)
how can i select one of each folder name because i know that there will be more than 1 folder name that is the same.
i have a mysql column called folder and there is a folder name in each row.

i want to display to the user his/her available folders BUT NOT REPEAT
how do i do that ?

i already know if i user SELECT folder FROM table then ill get them all how do i make it so i only get one of each name?

ok i get it. but is there anyway to omit certain answers? even if it is distinct ?

Use DISTINCT or group by:

1. select DISTINCT username from log.
2. select username from log group by username.

hi
i got that what you want means if xyz user log in than his/her folder only open right

so you need to add one column in folder table which is uid
means user's id

$query="select * from folder_table where uid=$uid";

$uid is current log in user id ok

I hope this code will usefull to you
Thanks

You should always have an identification column but you can just refer to the specific folder names you dont NEED an id column.

To omit certain answers you need to insert a WHERE clause in your statement ( I think it is a WHERE NOT clause) but it depends on your requirements and have to setup your own specfications.

SELECT * FROM TABLE WHERE NOT FOLDER_NAME = FOLDER_VALUE;
Member Avatar for diafol

Can you show your table structure (for all relevant tables) and use that to say what you want?

I assume (something like the following, obviously without all the fields :

user
id (PK)
username
pw
...

folders
id (PK)
foldername
user_id (ForeignKey user 'id')
....


msgs
id (PK)
sent (datetime)
from (ForeignKey - user 'id')
to (ForeignKey - user 'id')
status (e.g. tinyint, where 3 = draft 0 = unread, 1 = read, 2 = replied etc.)
folder_id (ForeignKey - folders 'id')
....

From these 2 tables you could then build a query with SELECT DISTINCT, INNER JOINS, and WHERE clauses to produce almost any output required.
Take a look at the MYSQL online manual for a full explanation of the correct syntax.

The folders table can be set up to have 4 folders created on member registration (e.g. inbox, outbox, drafts, sent). Obviously, 'msgs' table may need extra fields to cope with this.

If you download a version of something like phpBB3 and install the package (thereby creating phpbb3 mysql tables), you can look at that structure - it may help. Finding the code to go with that table within phpbb3 is a nightmare! But at least it'll give you an idea.

i actually have dl phpbb3 recently just to look at the tables. currently im only using 2 tables one for registrationa n profile information and 1 for the msges themselves which has one coulm for the folders. thats why i was looking to omit any. i just think that the where not solved the question i was asking. i do appreciate your responses. i was thinking about doingselect from folder where not foldername = "some folder i dont want in the list of folders" and i already have something else i figured out whcih omits the folder not having anything in it which would make it inbox. so the inbox folder doesnt show just the folders do. but thanks for the where not thats exactly what i was looking for. that makes a lot of sense. that would omit one folder or more i will have to look at the mysql manual thing for more information on these things. thanks for helping!!!!!!!!!!! i did already have select from member name where the members name is the same as the to member. and since the whole row has to member, form member message titile, message and folder ect.. then i was doing where the session username variable was equal to the two members so it would show all the msgs the user had that were his/hers. i dont know about an outbox. then i would have to mak another one for the from member equaled the session username variable and foldername equaled outbox (i think i would name it outbox or sent)
but im not sure i should make an outbox since once the message is deleted by the person it was too its deleted from the db. does anyone have any ideas for this pm system other than the move to folder feature, create folder feature, reply and forward and of course the delete feature. does anyone have any critism for how i am doing it(which i explained in this post) is there a better way (easier) to do it (or a safer way) im new to php so i wouldnt take it perrsonally.

Member Avatar for diafol

Sorry S, I'm getting trouble following you. With regard to the folders. Do whatever you ffel is right, but remember that deleted messages don't have to be deleted - just change the message 'status'. You could display a deleted folder (like most email systems). You could then use a further 'empty trash' command to actually wipe them from the db. My personal pref. for folders would be:

inbox
sent
trash
drafts

PMs are usually trivial things without too much impt info, so they don't require a complicated 'folder tree' like e-mail systems.

Can you post a simple image of the type of thing you need to produce?

i dont know what type of thing im just making it. i understand my last post was kind of long but u answered my question i didnt think about changing the status to deleted or whatever and not having it being deleted right away. but im worried that having messages that are sent would be o=in the databse forever. which would be in my opinion wasteful. i dont know maybe ill make a folder for sent messages that havent been opened. and u cant delete a messae without opening it first. so someone will know a msg has been atleast opened. then once is has been opened it will be deleted from the folder..
(like a pending message ) i dont understand what drafts would be? should people be able to edit their own messages or something? or save then send later?

Correct thats what a draft is.

A stored email for various reasons to be sent in the future.

well why do users nedd drafts anyways?

So they can come back and edit the email before it is sent.
Its a feature, you dont want them to have it, then dont.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.