checking values in 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

Post Reply
Craig
Forum Commoner
Posts: 37
Joined: Thu Apr 18, 2002 3:13 pm

checking values in database.......

Post by Craig »

Not the most descriptive topic title, and for that I apologise;

here's my problem - I just started back playing with php again - having not done anything for almost 9 months.......

Anyway, I have a table in my database where people put in either a 1,2 or an X into each of the 6 columns - what I've suddenly got stuck on is I want to check these 6 items against another 6 from a different table and produce a different result based on whether 2, 3, 4, 5 or 6 of the items matching up and I've got absolutely no idea how to do this, so can one of you fine people please help me out or give me a push in the right direction? Thanks.
User avatar
AVATAr
Forum Regular
Posts: 524
Joined: Tue Jul 16, 2002 4:19 pm
Location: Uruguay -- Montevideo
Contact:

Post by AVATAr »

illuminate us with an example and the table structur ur using
Craig
Forum Commoner
Posts: 37
Joined: Thu Apr 18, 2002 3:13 pm

Post by Craig »

Code: Select all

<?php
CREATE TABLE splpredict (
  matchday int(3) NOT NULL default '0',
  username text NOT NULL,
  game1 char(1) NOT NULL default '0',
  game2 char(1) NOT NULL default '0',
  game3 char(1) NOT NULL default '0',
  game4 char(1) NOT NULL default '0',
  game5 char(1) NOT NULL default '0',
  game6 char(1) NOT NULL default '0',
  pointsbet int(3) NOT NULL default '0',
  time int(10) NOT NULL default '0',
  KEY matchday (matchday)
) TYPE=MyISAM;

?>
That's my structure - so person A fills in the form which inserts the following into the above table;

game1 - X
game2 - 1
game3 - X
game4 - 1
game5 - 2
game6 - X

person B

game1 - X
game2 - 2
game3 - X
game4 - 1
game5 - 1
game6 - 1


In the other table 'Results' - that I haven't created yet but will be similar to the above structure with only game 1-6 being fields - then gets the actual results put into it which are;

gameresult1 - X
gameresult2 - 2
gameresult3 - X
gameresult4 - 2
gameresult5 - 2
gameresult6 - 1

So
Person A had 3 right (game1, game3 and game 5)
person B has 4 right (game1, game2, game3 and game6)

So I need to figure how I give person B something based on having 3 correct and likewise person B something different for having 4 correct.

Hope that makes sense to people.
Craig
Forum Commoner
Posts: 37
Joined: Thu Apr 18, 2002 3:13 pm

Post by Craig »

Not even a little shove in the right way to check each set in the database?

:cry:
Post Reply