Long time reader, first time poster, so please forgive what could be a stupid question...
I have a table in my database (I'm creating a Basketball Fantasy Keeper League Draft) that has the order of the draft (pick number, GM nominated to make that pick, picked player, the time the pick was made [there's a 12hr draft window] and whether the pick is a keeper pick or not) so what I'm trying to do is detect if the next pick is a keeper pick and if it is, run a few more queries, etc etc. I can do it if there is only ONE keeper pick where a GM would normally make a selection, but what happens if there are 2 or more keeper picks in a row?
So instead of doing a bunch of nested IF statements where I run a query selecting the next pick from the table and checking if it's a keeper pick or not 3 or 4 times (see below):
$query1Counter = "SELECT counterID FROM draftCounter";
$query1Result=mysql_query($query1Counter);
$livePickCount=mysql_numrows($query1Result);
then:
if ($livePickCount != "") {
//Do stuff then:
//run $query1Counter again, then:
if ($livePickCount != "") {
//Do stuff then:
//run $query1Counter again
if ($livePickCount != "") {
//Do stuff then:
//run $query1Counter again
}
}
}
I was hoping that I could pull ALL the results from the table like:
query = SELECT * FROM keeperLeagueDraftOrder;
$result=mysql_query($query);
pull out the specific column value like:
$keeperPick=mysql_result($result,$i,"keeperPick");
and then, since it's either 1 for a Keeper Pick and 0 for a normal pick, possibly do a loop like:
WHILE $keeperPick=1 {
//Do all the stuff that would skip the row here
}
So that it loops in case there are 2 or more Keeper pics in a row, otherwise, once it gets to the first value where keeperPick==0
, then it goes about it's normal business.
My problem is that I'm not a proper programmer and am only fudging my way through this stuff by googling and copy/pasting and some tweaking where needed, and only used to really simple loops.
Sample table (where the first draft pick has been made as well as 4 Keeper picks nominated [no draft time]):
draftPickID draftPickPlayerID draftPickGM keeperPick draftTime
1 72 5 0 2012-09-10 22:04:24
2 10 3 1 0000-00-10 00:00:00
3 32 2 1 0000-00-10 00:00:00
4 0 6 0 0000-00-10 00:00:00
5 0 1 0 0000-00-10 00:00:00
6 5 4 1 0000-00-10 00:00:00
7 44 4 1 0000-00-10 00:00:00
8 0 1 0 0000-00-10 00:00:00
9 0 6 0 0000-00-10 00:00:00
10 0 2 0 0000-00-10 00:00:00