How to show.....
Moderator: General Moderators
- robynprivette
- Forum Commoner
- Posts: 46
- Joined: Sun May 02, 2010 6:22 pm
How to show.....
I have a db named scrolls.
there is one table inside the db containing two fields user & code
I want to show ALL codes from the table that match the user field. how would I do this?
For example:
a user has three code entries and i want to show all entries from the user
there is one table inside the db containing two fields user & code
I want to show ALL codes from the table that match the user field. how would I do this?
For example:
a user has three code entries and i want to show all entries from the user
Re: How to show.....
Code: Select all
SELECT field FROM table WHERE foo = bar- robynprivette
- Forum Commoner
- Posts: 46
- Joined: Sun May 02, 2010 6:22 pm
Re: How to show.....
what do i put for foo and bar??tasairis wrote:Substitute "field", "table", and "foo = bar" as needed.Code: Select all
SELECT field FROM table WHERE foo = bar
- robynprivette
- Forum Commoner
- Posts: 46
- Joined: Sun May 02, 2010 6:22 pm
Re: How to show.....
i don't think i was clear enough. say user Silver is in the column user three times. there are three different codes in column code beside the name Silver. I want to echo the user's name and then all the codes entered by that user
Re: How to show.....
You were clear enough, I just didn't give you the full answer that you wanted to hear. I'm expecting you to learn a little SQL and PHP.
SELECT query syntax
PHP+MySQL tutorials
SELECT query syntax
PHP+MySQL tutorials
- robynprivette
- Forum Commoner
- Posts: 46
- Joined: Sun May 02, 2010 6:22 pm
Re: How to show.....
i know i'm trying... i've been googling and reading and trying things till i'm blue in the face!! that's why i came here....tasairis wrote:You were clear enough, I just didn't give you the full answer that you wanted to hear. I'm expecting you to learn a little SQL and PHP.
SELECT query syntax
PHP+MySQL tutorials
Re: How to show.....
The query is basically
Any PHP+MySQL tutorial will show you how to print the results of that query.
Code: Select all
SELECT code FROM table WHERE user = "Silver"- robynprivette
- Forum Commoner
- Posts: 46
- Joined: Sun May 02, 2010 6:22 pm
Re: How to show.....
there are other users too though. i want to echo everyone's codes under their nametasairis wrote:The query is basicallyAny PHP+MySQL tutorial will show you how to print the results of that query.Code: Select all
SELECT code FROM table WHERE user = "Silver"
Re: How to show.....
Then select everything, order by the person's name, perhaps sort by code too, and loop through it all:
1. Fetch a row
2. If the previous row's user doesn't match the current row's user (or if this is the first row) then you're showing codes for a new person
3. Print the code
4. Go to 1
1. Fetch a row
2. If the previous row's user doesn't match the current row's user (or if this is the first row) then you're showing codes for a new person
3. Print the code
4. Go to 1