Jump to content

Help - help needed to update my table?


ICEcoffee

Recommended Posts

Hi all

I am learning PHP slowly (all the code below is handwritten by me, cool eh?), but I can't work out why my leaderboard table is not being updated properly.

I am trying to match driver names from the race results from table "t_qualy_results",
with driver names in a users team tables "ff1_teams"
and update previously created rows within the leaderboard table "ff1_leaderboard".

I think it is the actual update statment for updating the leaderboard table that is wrong, but it may also be the logical stucture is wrong too.

Please help, It's driving me nuts.

Cheers

[code]
            <?php
                // insert rows into Leaderboard table
                //
                echo "race variables";
                mysql_select_db($database_FF1, $FF1);
                $raceq = ('SELECT RaceID FROM races WHERE CurrentRace = 1');
                $raceresult = mysql_query($raceq) or die(mysql_error());
                $row = mysql_fetch_array($raceresult);                
                $rownum = mysql_numrows($raceresult);
                //
                $ff1q = ('SELECT TeamName, id FROM ff1_teams WHERE Active = 1') or die(mysql_error());
                $ff1qresult = mysql_query($ff1q) or die(mysql_error());;
                while($teamrow = mysql_fetch_array( $ff1qresult )) {
                    $leaderq = "INSERT INTO ff1_leaderboard (RaceID, TeamID, TeamName) VALUES ('$row[RaceID]', '$teamrow[id]', '$teamrow[TeamName]')";
                    mysql_query($leaderq) or die(mysql_error());
                }
                //
                // Update Leaderboard with Qualifier results
                //
                
                echo "raceID = ", $row['RaceID'];
                            
                // now look through qualy points
                
                
                $qualyq = ("SELECT * FROM t_qualy_results WHERE t_qualy_results.RaceID = '".$row['RaceID']."'") or die(mysql_error());
                $qualyr = mysql_query($qualyq) or die(mysql_error());
                
                while($qualyrow = mysql_fetch_array($qualyr)) {
                     
                        $ff1q = ('SELECT * FROM ff1_teams WHERE ff1_teams.Active = 1')or die(mysql_error());
                        $ff1r = mysql_query($ff1q) or die(mysql_error());
                        
                             while($ff1row = mysql_fetch_array($ff1r)){
                                 echo " - inner loop ", $iloop;
                                if ($qualyrow['Driver'] == $ff1row['Driver1']){
                                    
                                    $query = "UPDATE ff1_leaderboard WHERE ff1_leaderboard.RaceID = ".$row['RaceID']." AND  ff1_leaderboard.TeamID =  ". teamrow['TeamID']." SET Driver1= '$qualyrow[Driver]'" or die(mysql_error());
                                    $result = mysql_query($query) or die(mysql_error());
                                    
                                }
                                
                            }
                
                    }
            ?>[/code]

[b]EDIT BY OBER: PLEASE USE CODE TAGS WHEN POSTING CODE[/b]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.