chriscloyd Posted April 25, 2007 Share Posted April 25, 2007 I have this script that updates teams ranks and what not i had 200 teams and it took forever to load the page is there a way i can add a progress script to show how long it will take? http://www.chaoslegionclan.net/cegl/files/admin_updateranks.php?division_id=1&confrence_id=1 Quote Link to comment Share on other sites More sharing options...
taith Posted April 25, 2007 Share Posted April 25, 2007 not using php... its server side... you'd need something like... javascript/ajax to do progress bars... Quote Link to comment Share on other sites More sharing options...
chriscloyd Posted April 25, 2007 Author Share Posted April 25, 2007 the script runs in php tho Quote Link to comment Share on other sites More sharing options...
taith Posted April 25, 2007 Share Posted April 25, 2007 well... if your buffering your information... then i suppose you can use ob_flush() to output a progress bar... it'd be tough... but doable... Quote Link to comment Share on other sites More sharing options...
chriscloyd Posted April 25, 2007 Author Share Posted April 25, 2007 hmm how would i find info about that and buffering the info? Quote Link to comment Share on other sites More sharing options...
chriscloyd Posted April 25, 2007 Author Share Posted April 25, 2007 Im up for challenges Quote Link to comment Share on other sites More sharing options...
taith Posted April 25, 2007 Share Posted April 25, 2007 http://us.php.net/manual/en/function.ob-flush.php but youd have to get VERY creative... if it were me... i'd build it via javascrip/ajax... Quote Link to comment Share on other sites More sharing options...
chriscloyd Posted April 25, 2007 Author Share Posted April 25, 2007 ya if i knew javascript and ajax well i would lol Quote Link to comment Share on other sites More sharing options...
roopurt18 Posted April 25, 2007 Share Posted April 25, 2007 Why don't you just implement the script as a cron job? Then you don't have to log in as the admin and waste your time waiting for the script to finish. Even if you implement a progress bar, eventually you will reach a point where there are so many teams that the script takes longer than your webserver's timeout period. Quote Link to comment Share on other sites More sharing options...
chriscloyd Posted April 25, 2007 Author Share Posted April 25, 2007 the script is really easy <?php include("config.php"); $get_Teams = mysql_query("SELECT * FROM teams WHERE division_id = '".$_GET['division_id']."' AND team_confrence = '".$_GET['confrence_id']."' ORDER by `team_wins` DESC, `team_loses` ASC, `team_ties` ASC, `team_roundw` DESC, `team_roundl` ASC, `team_forfeitw` ASC, `team_forfeitl` DESC") or die(mysql_error()); $rank = 0; while ($team_rank = mysql_fetch_array($get_Teams)) { $rank++; $update_rank = mysql_query("UPDATE teams SET team_rank = '".$rank."' WHERE team_id = '".$team_rank['team_id']."'"); if ($update_rank) { echo '-Updated Rank For Team '.$team_rank['team_name'].' From '.$team_rank['team_rank'].' To '.$rank.'<br />'; } else { echo '-Could not update the rank for team '.$team_rank['team_name'].'<br />'; } } ?> I tried it with 700 teams and it didnt timeout Quote Link to comment Share on other sites More sharing options...
roopurt18 Posted April 25, 2007 Share Posted April 25, 2007 A couple of items: You're not sanitizing your values before putting them in your query. Why are you using 'SELECT * FROM' when the only values you're using in the loop are team_id, team_name, and team_rank? If there are extra fields in the table, or if you add fields later, you are just pulling out extra data you'll never use. 'SELECT team_id, team_name, team_rank FROM' would be better IMO. You could probably do this in one query with some form of UPDATE ... SELECT, although I'm not sure how exactly. Lastly, just because the script is simple doesn't mean it's not suitable as a cron job. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.