Greaser9780 Posted March 19, 2007 Share Posted March 19, 2007 I am currently running a class to execute screen scrapes from a general stats page. Currently it is set to print out the arrays. How can I utilize and organise this data so I can then enter it into my database? Quote Link to comment Share on other sites More sharing options...
per1os Posted March 19, 2007 Share Posted March 19, 2007 Can you provide some examples? Hard to work when your blind with both hands tied behind your back. Quote Link to comment Share on other sites More sharing options...
Greaser9780 Posted March 19, 2007 Author Share Posted March 19, 2007 Sorry. Here is an example from NFL.com. I scraped a certain years stats then it printed this as the array:  Array (   [0] => Array     (       [0] => Game Log     )   [1] => Array     (       [0] =>     )   [2] => Array     (       [0] => September       [1] => Rushing       [2] => Receiving       [3] => Fumbles     )   [3] => Array     (       [0] => GAMEDATE       [1] => Opp       [2] => RESULT       [3] => GS       [4] => Att       [5] => Yds       [6] => Avg       [7] => Lg       [8] => TD       [9] => Rec       [10] => Yds       [11] => Avg       [12] => Lg       [13] => TD       [14] => Fum       [15] => Rec       [16] => Yds       [17] => TD     )   [4] => Array     (       [0] => 09/11       [1] => @OAK       [2] => W 27-0       [3] => Yes       [4] => 31       [5] => 131       [6] => 4.2       [7] => 58       [8] => 1       [9] => 3       [10] => 18       [11] => 6.0       [12] => 10       [13] => 0       [14] => 0       [15] => 0       [16] => 0       [17] => 0     ) Quote Link to comment Share on other sites More sharing options...
per1os Posted March 19, 2007 Share Posted March 19, 2007 Maybe enclosing it in [ code ] and [ /code ] tags may help us see it better? Quote Link to comment Share on other sites More sharing options...
Greaser9780 Posted March 19, 2007 Author Share Posted March 19, 2007 Ok now you can scroll it. Quote Link to comment Share on other sites More sharing options...
per1os Posted March 19, 2007 Share Posted March 19, 2007 Do you have the MySQL table structure you were going to insert it into? Quote Link to comment Share on other sites More sharing options...
Greaser9780 Posted March 19, 2007 Author Share Posted March 19, 2007 I was just going to set it up in the same order as the array. I haven't created it yet. Just wondering how the code needs to be structured so that I can run it in a query. Quote Link to comment Share on other sites More sharing options...
per1os Posted March 19, 2007 Share Posted March 19, 2007 It really all depends on how the database is done. If you are going to be parsing a string for the GAMEDATA than you you can use 1 table to enter all the data in and just set : or something similar as the separator string. If you want to store each value into its own field, well that calls for multiple tables. Here is the example for what I stated above: Â <?php $log = $nflArr[0][0]; //$data = $nflArr[1]; foreach ($nflArr[1] as $data) { $entry .= $data . ":"; } $entry = substr($entry, 0, -1); foreach ($nflArr[3] as $gData) { $gameData .= $gData . ":"; } $gameData = substr($gameData, 0, -1); foreach ($nflArr[4] as $date) { $dayData .= $date . ":"; } $dayData = substr($dayData, 0, -1); mysql_query("INSERT INTO tblName `entry`, `gamedata`, `daydata` VALUES('".$entry."', '".$gameData."', '".$dayData."'"); ?> Quote Link to comment Share on other sites More sharing options...
Greaser9780 Posted March 20, 2007 Author Share Posted March 20, 2007 Actually what I am looking to do is gather the info(already done). Then I want to take each stat and create a number out of it. Example: A touchdown is worth 6 points. $tdpoints = ($touchdowns * 6). So I guess I'm wondering do I need to insert it into a db first and then in another script pull it out and do the math on it, OR can I just do the math somehow before inserting it into the db. Also I am not looking to utilize all the arrays gathered. I just want to use the stats from the day that I am choosing. But with mmy class it extracts all the data after a certain phrase in the page. Quote Link to comment Share on other sites More sharing options...
Greaser9780 Posted March 20, 2007 Author Share Posted March 20, 2007 Nevermind. I figured it out finally. First time messing with arrays. I needed to experiment quite alot. 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.