Page 1 of 1

DataBase

Posted: Tue Jan 09, 2007 5:57 pm
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

Posted: Tue Jan 09, 2007 8:42 pm
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.

Thanks!

Posted: Tue Jan 09, 2007 9:49 pm
by ykarmi
Second time you're helping me today!
THANK YOU SOOO SOOO MUCH!
Yuval :D

Posted: Tue Jan 09, 2007 9:51 pm
by aaronhall
Just quit cross-posting your threads -- the big guys around here don't take very kindly to it.