Jump to content

[SOLVED] Need a little help with modifying this script


jwer78

Recommended Posts

Hi all I need a little help with modifying this script. It reads from a txt file and dumbs the data into the database. Well the txt file has some new data displayed for the defense, in particular CTH Allow and Big Hit. I added these to the line but it still isnt reading them and dumping the data. Im sure I am missing something so any help would be appreciated. Thanks in advance.

elseif(
                    $line=="PASSING                        CMP  ATT  YDS  PCT   YPA SACK   TD  INT LONG RATING\n" ||
                    $line=="RUSHING                        ATT  YDS   AVG LONG   TD  FUM\n" ||
                    $line=="RECEIVING                      REC  YDS   AVG LONG   TD DROP  YAC\n" ||
                    $line=="KICKING                        FGM  FGA  PCT FGSBLOCKED  XPA  XPM  PCT XPSBLOCKED KICKOFFS TOUCHBACKS\n" ||
                    $line=="PUNTING                        ATT  YDS   AVG LONG BLOCKS IN20 TOUCHBACKS\n" ||
                    $line=="DEFENSE                        TOT LOSS SACK   FF FREC  YDS   TD  INT  RET   AVG DEFLECTIONS SAFETIES CTH ALLOW BIG HITS\n" ||
                    $line=="BLOCKING                      PANCAKES SACKS ALLOWED\n"
                ){
                    $category = preg_split ("/[\s,]+/", strtolower($line));
                    $num_categories = count($category);
                    $num_categories--;

                    $table="game_" . $category[0];

                    $variable_array[0]=$category[0] . "_player";

                    for($count=1; $count<$num_categories; $count++)
                        $variable_array[$count]= $category[0] . "_" .$category[$count];

                    $line = @fgets ($fp, 1024);

                    while (substr($line,0,1)!="\n"){
                        $line = ereg_replace ("\'","",$line);

                        $data = preg_split ("/[\s,]+/", trim(substr($line, 30, 1000)));
                        $$variable_array[0] = trim(substr($line, 0, 29));

                        for($count=1; $count<$num_categories; $count++)
                            $$variable_array[$count] = $data[$count-1];

                        $query_name = "game_" . $category[0];

                        $$query_name = "INSERT into $table values('','$game_id','$active_team'";

                        for($count=0; $count<$num_categories; $count++)
                           $$query_name = $$query_name . ",'" . trim($$variable_array[$count]) . "'";

                        $$query_name = $$query_name . ")";

                        echo $$query_name . "<BR>";

                        $res=mysql_query($$query_name,$db);

                        $line = @fgets ($fp, 1024);
                    }
                }

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.