JSLayton Posted April 7, 2008 Share Posted April 7, 2008 How could I accomplish this same task WITHOUT involving MySQL?? I'm assuming I can use either OOP or Arrays, but not sure the best way to go about it. PLEASE HELP!! $query = "TRUNCATE TABLE `temp_results_table`"; mysql_query($query); $query = "SELECT * FROM coaches WHERE sport='".$sport."' AND league='".$league."'"; $results = mysql_query($query); while ($row = mysql_fetch_assoc($results)) { $query = "INSERT INTO temp_results_table (teamname, wins, losses, pointdiff) VALUES ('".$row['name']."', 0, 0, 0)"; mysql_query($query); } $query = "SELECT * FROM results WHERE sport='".$sport."' AND league='".$league."' AND (awayscore IS NOT NULL AND homescore IS NOT NULL)"; $results = mysql_query($query); while ($row = mysql_fetch_assoc($results)) { if ($row['awayscore'] < $row['homescore']) { $winner = $row['home']; $loser = $row['away']; $pointdiff = $row['homescore'] - $row['awayscore']; } else { $winner = $row['away']; $loser = $row['home']; $pointdiff = $row['awayscore'] - $row['homescore']; } $query = "UPDATE temp_results_table SET wins = wins + 1, pointdiff = pointdiff + ".$pointdiff." WHERE teamname = '".$winner."'"; mysql_query($query); $query = "UPDATE temp_results_table SET losses = losses + 1 WHERE teamname = '".$loser."'"; mysql_query($query); } $query = "SELECT * FROM temp_results_table ORDER BY wins DESC, losses ASC, pointdiff DESC"; $results = mysql_query($query); while ($row = mysql_fetch_assoc($results)) { echo $row['teamname']." "; echo $row['wins']." "; echo $row['losses']." "; echo $row['pointdiff']." "; echo "<br />"; } Link to comment https://forums.phpfreaks.com/topic/99964-need-more-effecient-way-of-writing-working-code/ Share on other sites More sharing options...
Cep Posted April 7, 2008 Share Posted April 7, 2008 Your request doesn't make any sense. MySQL is a database, which looking at your script is where your data is coming from. If you don't want to use MySQL pick any other database out there or alternative use a flat file system (not recommended) for your data storage. Link to comment https://forums.phpfreaks.com/topic/99964-need-more-effecient-way-of-writing-working-code/#findComment-511194 Share on other sites More sharing options...
Thread7 Posted April 7, 2008 Share Posted April 7, 2008 Sorry to everyone. I was looping through 30 times but only 6 times did it actually have values in $entryid. So I was getting the error in those cases. Link to comment https://forums.phpfreaks.com/topic/99964-need-more-effecient-way-of-writing-working-code/#findComment-511362 Share on other sites More sharing options...
cooldude832 Posted April 7, 2008 Share Posted April 7, 2008 Sorry to everyone. I was looping through 30 times but only 6 times did it actually have values in $entryid. So I was getting the error in those cases. so is this your problem? and is it solved? Link to comment https://forums.phpfreaks.com/topic/99964-need-more-effecient-way-of-writing-working-code/#findComment-511390 Share on other sites More sharing options...
Barand Posted April 7, 2008 Share Posted April 7, 2008 As for your original question, you could certainly replace temp_results_table with an array. Link to comment https://forums.phpfreaks.com/topic/99964-need-more-effecient-way-of-writing-working-code/#findComment-511411 Share on other sites More sharing options...
JSLayton Posted April 7, 2008 Author Share Posted April 7, 2008 What I meant was the end of the code, where I was putting the code into a temp database table only to pull it back out. I was using it for sorting purposes because I knew how to make it work. I was able to get it into an array which I then sorted using array_multisort. Link to comment https://forums.phpfreaks.com/topic/99964-need-more-effecient-way-of-writing-working-code/#findComment-511534 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.