F@H: PHP / MySql programmer help appreciated

Soldato
Joined
18 Oct 2002
Posts
10,573
Location
Seattle
I'm a numpty, completely and utterly. I fudge my way through php / mysql learning commands as necessary to tweak existing scripts. What I'm not good at is actually writing programs from scratch / designing programs from scratch. I thought I'd query here as its a much more interested market.
Something I've been pondering for quite a few months now is an automated way of producing the same (or 99%) of the stats that go into the weekly F@H stats.

In theory this should be simple.

Every couple of hours or so my server grabs

http://vspx27.stanford.edu/teamstats/team10.txt

then clears the db:
Code:
$sql = 'DELETE FROM `fah`';
$result = mysql_query($sql);

$sql = 'DELETE FROM `teamrank`';
$result = mysql_query($sql);

and then explodes the text file (stored as $fp)
Code:
/* Take the rank and insert it into a seperate table in the DB */
$teampos = $fp[6];
$pieces = explode (" ",$teampos);
$query = "INSERT INTO `teamrank` (`rank`) VALUES ('".$pieces[2]."')";
$result = mysql_query($query);

/* Grab all the user data from the source and put it into a table */
$number_of_lines = count($fp);
for ($i=10; $i<$number_of_lines; $i++)
        {
        //split up each line
        $line = explode( "\t", $fp[$i]);
        $query = "INSERT INTO `fah` (`rank`, `teamrank`, `name`, `credit`, `total`, `workunits`) VALUES ('".$line$
        $result = mysql_query($query);
        }
?>


If there is anyone with good php / mysql skills around and fancies having a stab, I'm confident this should be easy to achieve, and just as easy to make the output bbcode friendly too :)
 
Pumpkinstew said:
I can do the rotating sig bit it's having the stats from boinc projects update live onto each one that's awkward.

ie rotates through Seti Sig>Einstein Sig>Rosetta Sig>LHC Sig etc

Hmm..

Code:
<?php
srand((double)microtime()*10000000);
$dir = 'images';
$h = opendir($dir);
while($f = readdir($h))
        if(!is_dir($dir.'/'.$f))
                $imgs[count($imgs)] = $f;
header('Location: '.$dir.'/'.$imgs[array_rand($imgs)]);
?>
]);
?>

Thats all my rotating sig is. In theory it should be easy to have that read in a random script from a subfolder, which in turn will do the necessary jiggery pokery to return the relevant stats / image.
 
Back
Top Bottom