DataBase

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Locked
ykarmi
Forum Commoner
Posts: 35
Joined: Mon Oct 30, 2006 4:45 pm

DataBase

Post by ykarmi »

Hey Guys,
I have a website, in which a user can choose to predict soccer games every week, but in order for him/her to predict the week, they need to buy it first. I have no problems with the buying part, but the data of the weeks bought should be entered into a database. I have three rows in my data base: username, pass, weeksbought.
Now, I have a page that checks what weeks were paid, it consists of a list that looks like this: (EX.1)
Week 1
Week 2
Week 3
Week 4
etc...

Right next to those values, there will be a word displayed. so say a user bought week 1 and 3 it would do this:
Week 1 Paid
Week 2 Unpaid
Week 3 Paid
Week 4 Unpaid
...

So I need to somehow check with the database whether a week was paid or not. Can the row weeksbought display numbers separated by a comma? something like this?
1,3
If so, How can I read from those weeks into the PHP file that displays what weeks were paid and what weeks were unpaid? (refer to EX. 1)

Thank you sooooo much people.
Yours,
Yuval Karmi
User avatar
aaronhall
DevNet Resident
Posts: 1040
Joined: Tue Aug 13, 2002 5:10 pm
Location: Back in Phoenix, missing the microbrews
Contact:

Post by aaronhall »

If you haven't already, set up your table so that there is one row for every week paid.

Code: Select all

create table weeks_paid (
  id int(11) auto_increment not null,
  userID int(11),
  week_number int,
  primary key(id)
)
As long as you have the userID, you can easily query the database for all weeks paid, or check if a single week has been paid.
ykarmi
Forum Commoner
Posts: 35
Joined: Mon Oct 30, 2006 4:45 pm

Thanks!

Post by ykarmi »

Second time you're helping me today!
THANK YOU SOOO SOOO MUCH!
Yuval :D
User avatar
aaronhall
DevNet Resident
Posts: 1040
Joined: Tue Aug 13, 2002 5:10 pm
Location: Back in Phoenix, missing the microbrews
Contact:

Post by aaronhall »

Just quit cross-posting your threads -- the big guys around here don't take very kindly to it.
Locked