Jump to content

[SOLVED] progress meter


chriscloyd

Recommended Posts

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

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.