I give up.. I would concider myself a seasoned PHP programmer, but this one is giving me a serious headache. 🙁
A friend has asked me to write them a small script that reads a list of names from a database of golf players, and then randomly selects pairs to play against each other, displaying the list back to the browser user. There is a field in the database that shows who last played who, and this needs to be used by the generation part of the script to ensure two people don't end up playing each other twice in a row.
I have to say, I am stumped on how to go about this. Can anyone give any pointers? I'm not asking for complete code, just some hints.
The list is retrieved by this piece of code (but I can scrap this if needed, it's just to give an idea of what's going on so far with my attempt):
$sql = "SELECT id,name,last_played FROM ngp_names";
if (DB::isError( $db_player_list = $db->query($sql))) {
echo DB::errorMessage($db_player_list);
} else {
while ($db_player_list_row = $db_player_list->fetchRow()) {
$id = $db_player_list_row["0"];
$name = $db_player_list_row["1"];
$last_played = $db_player_list_row["2"];
$players["$id"]["name"] = $name;
$players["$id"]["played"] = $last_played;
}
}
Thanks for your help.