SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict
    Join Date
    Mar 2011
    Location
    Manchester, UK
    Posts
    226
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Search MySQL Table That Has More Than 1 Value?

    Hi Guys,

    I'm currently stuck on an issue i have which i will try and explain to the best of my ability and try and explain what I'm trying to achieve.

    Right I'm in the middle of creating an affiliate network using PHP & MySQL. I have a table called Programs which looks like the following:



    Now what im trying to do is do it so affiliates need to apply to the program in order to be able to run it. Now i'm trying to think of the best way in order to do this and one idea i had was to add 2 new fields in the table called Programs at the end and call them 'PendingAffiliates' and 'ApprovedAffiliates' and for example lets say affiliate id 2,7,24 and 29 applied to run programid 1 and affiliate id 1,3,4,5 where approved to run the program the table would now look like this:



    Now the problem i have is i dont know what code i would use to check if the affiliateid was pending or approved to run that program because the value of pendingaffiliates and approvedaffiliates would have more than 1 value in them. Can you suggest a way of doing this or a better way of doing this please.

    If you have any questions feel free to ask, any help would be great.

    Thank you!

  2. #2
    SitePoint Wizard
    Join Date
    Oct 2005
    Posts
    1,834
    Mentioned
    5 Post(s)
    Tagged
    1 Thread(s)
    Your method is not a good one. That's for sure. Why don't you just create a second table and join the two when needed?

  3. #3
    SitePoint Guru aamonkey's Avatar
    Join Date
    Sep 2004
    Location
    kansas
    Posts
    953
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    cheesedude is right - you'll need 3 tables to accomplish this:

    Code:
    Programs
    ------------------------
    id
    image
    name
    description
    url
    affPayout
    newPayout
    country
    status
    
    
    Affiliates
    ------------------------
    id
    name
    (etc)
    
    
    AffiliatePrograms
    ------------------------
    id
    affiliateId
    programId
    status (i.e. 1 for pending, 2 for approved)
    then you can join the AffiliatePrograms table to find the information you need.
    aaron-fisher.com - PHP articles and more


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •