Jump to content

cowboysdude

Members
  • Posts

    123
  • Joined

  • Last visited

Posts posted by cowboysdude

  1. I am not sure why this just isn't coming to me but for some reason it's stumping how to properly parse this thing!!  

     

    Every line has it's own entry and trying to get the info for each match is proving somewhat puzzling for me! I can get any of the info but how for instance can I get both teams together since each team has it's own line and each match has 2 lines in it....   I'm trying to pull the data then make a table out of it but for some reason it's just escaping me totally.... 

     

    http://www03.myfantasyleague.com/2012/export?TYPE=nflSchedule&W=19

     

    That is the xml file...

     

    $team1 = $games->attributes()->id;   that is how I am getting it but it return both teams..... how can I do this line by line?  Any suggestions would be helpful!

     

    Thanks!  

  2. Appreciate the input!   But I'm thinking they added this to separate the 'content'

     

    media: category

     

    So it won't go past the 4th one... so I have to figure out my way around that one.  You can see it when you go here:

     

    http://codebeautify.org/  and input your xml... it gives you an html 'tree view'.... 

     

    So another adventure... :)

  3. Well I'm having a similar issue.. the following is only returning 2 results... there are many more..... cannot seem to figure out why...

    $feed = file_get_contents("http://www.dallascowboys.com/rss/video");
    $xml = new SimpleXmlElement($feed);
    foreach ($xml->channel->item as $entry){
        $date = $entry->pubDate;
    	$title= $entry->title;
      $namespaces = $entry->getNameSpaces(true);
      $media = $entry->children($namespaces['media']);
      $date = $entry->pubDate;
      $title= $entry->title;
      $des= $entry->description;
      $link = $media->group->content[4]->attributes()->url;
      $thumb = $media->group->content[2]->thumbnail[3]->attributes()->url;
    

    Like I said this is returning 2 of the many possible results....

     

    Anyone have any insight as to why?  

     

    Thanks everyone!!! :)

  4. Here are my arrays.  I'm using a search and replace with them...

    $find = array(
          "TBD",
          "ARI",
          "ATL",
          'BAL',
          'BUF',
          'CAR',
          'CHI',
          'CIN',
          'CLE',
          'DAL',
          'DEN',
          'DET',
          'GB',
          'HOU',
          'IND',
          'JAC',
          'KC',
          'MIA',
          'MIN',
          'NE',
          'NO',
          'NYJ',
          'NYG',
          'OAK',
          'PHI',
          'PIT',
          'STL',
          'SD',
          'SF',
          'SEA',
          'TB',
          'TEN',
          'WAS',
          'RIC',
          'IRV'
          
      );
      
      $replace = array(
        "<img src='". JUri::base() ."/modules/mod_scores/assets/img/teams/tbd.png'>   TBD</a>",
        "<a href='http://www.azcardinals.com/' target='_blank'><img src='". JUri::base() ."/modules/mod_scores/assets/img/teams/cards.png'>   Cardinals</a>", 
        "<a href='http://www.atlantafalcons.com/' target='_blank'><img src='". JUri::base() ."/modules/mod_scores/assets/img/teams/falcons.png' >   Falcons</a>", 
        "<a href='http://www.baltimoreravens.com/' target='_blank'><img src='". JUri::base() ."/modules/mod_scores/assets/img/teams/ravens.png' >   Ravens</a>", 
        "<a href='http://www.buffalobills.com/' target='_blank'><img src='". JUri::base() ."/modules/mod_scores/assets/img/teams/bills.png' >   Bills</a>", 
        "<a href='http://www.panthers.com/' target='_blank'><img src='". JUri::base() ."/modules/mod_scores/assets/img/teams/panthers.png' >   Panthers</a>", 
      	"<a href='http://www.chicagobears.com/' target='_blank'><img src='". JUri::base() ."/modules/mod_scores/assets/img/teams/bears.png' >   Bears</a>", 
      	"<a href='http://www.bengals.com/' target='_blank'><img src='". JUri::base() ."/modules/mod_scores/assets/img/teams/bengals.png' >   Bengals</a>", 
      	"<a href='http://www.clevelandbrowns.com/' target='_blank'><img src='". JUri::base() ."/modules/mod_scores/assets/img/teams/browns.png' >   Browns</a>", 
      	"<a href='http://www.dallascowboys.com/' target='_blank'><img src='". JUri::base() ."/modules/mod_scores/assets/img/teams/cowboys.png' >   Cowboys</a>", 
      	"<a href='http://www.denverbroncos.com/' target='_blank'><img src='". JUri::base() ."/modules/mod_scores/assets/img/teams/broncos.png' >   Broncos</a>", 
      	"<a href='http://www.detroitlions.com/' target='_blank'><img src='". JUri::base() ."/modules/mod_scores/assets/img/teams/lions.png' >   Lions</a>", 
      	"<a href='http://www.packers.com/' target='_blank'><img src='". JUri::base() ."/modules/mod_scores/assets/img/teams/packers.png' >   Packers</a>", 
      	"<a href='http://www.houstontexans.com/' target='_blank'><img src='". JUri::base() ."/modules/mod_scores/assets/img/teams/texans.png' >   Texans</a>", 
      	"<a href='http://www.colts.com/' target='_blank'><img src='". JUri::base() ."/modules/mod_scores/assets/img/teams/colts.png' >   Colts</a>", 
      	"<a href='http://www.jaguars.com/' target='_blank'><img src='". JUri::base() ."/modules/mod_scores/assets/img/teams/jags.png' >   Jaguars</a>", 
      	"<a href='http://www.chiefs.com/' target='_blank'><img src='". JUri::base() ."/modules/mod_scores/assets/img/teams/chiefs.png' >   Chiefs</a>", 
      	"<a href='http://www.miamidolphins.com/' target='_blank'><img src='". JUri::base() ."/modules/mod_scores/assets/img/teams/dolphins.png' >   Dolphins</a>", 
      	"<a href='http://www.vikings.com/' target='_blank'><img src='". JUri::base() ."/modules/mod_scores/assets/img/teams/viks.png' >   Vikings</a>", 
      	"<a href='http://www.patriots.com/' target='_blank'><img src='". JUri::base() ."/modules/mod_scores/assets/img/teams/pats.png' >   Patriots</a>", 
      	"<a href='http://www.neworleanssaints.com/' target='_blank'><img src='". JUri::base() ."/modules/mod_scores/assets/img/teams/saints.png' >   Saints</a>",
      	"<a href='http://www.newyorkjets.com/' target='_blank'><img src='". JUri::base() ."/modules/mod_scores/assets/img/teams/jets.png' >   Jets</a>",
      	"<a href='http://www.giants.com/' target='_blank'><img src='". JUri::base() ."/modules/mod_scores/assets/img/teams/giants.png' >   Giants</a>", 
      	"<a href='http://www.raiders.com/' target='_blank'><img src='". JUri::base() ."/modules/mod_scores/assets/img/teams/raiders.png' >   Raiders</a>", 
      	"<a href='http://www.philadelphiaeagles.com/' target='_blank'><img src='". JUri::base() ."/modules/mod_scores/assets/img/teams/eagles.png' >   Eagles</a>", 
      	"<a href='http://www.steelers.com/' target='_blank'><img src='". JUri::base() ."/modules/mod_scores/assets/img/teams/steelers.png' >   Steelers</a>",
       	"<a href='http://www.stlouisrams.com/' target='_blank'><img src='". JUri::base() ."/modules/mod_scores/assets/img/teams/rams.png' >   Rams</a>", 
      	"<a href='http://www.chargers.com/' target='_blank'><img src='". JUri::base() ."/modules/mod_scores/assets/img/teams/chargers.png' >   Chargers</a>", 
      	"<a href='http://www.49ers.com/' target='_blank'><img src='". JUri::base() ."/modules/mod_scores/assets/img/teams/49ers.png' >   49ers</a>", 
      	"<a href='http://www.seahawks.com/' target='_blank'><img src='". JUri::base() ."/modules/mod_scores/assets/img/teams/seahawks.png' >   Seahawks</a>", 
      	"<a href='http://www.buccaneers.com/' target='_blank'><img src='". JUri::base() ."/modules/mod_scores/assets/img/teams/bucs.png' >   Buccaneers</a>", 
      	"<a href='http://www.titansonline.com/' target='_blank'><img src='". JUri::base() ."/modules/mod_scores/assets/img/teams/titans.png' >   Titans</a>", 
      	"<a href='http://www.redskins.com/' target='_blank'><img src='". JUri::base() ."/modules/mod_scores/assets/img/teams/redskins.png' >   Redskins</a>", 
      	"Team Rice",
      	"Team Irving"
        );
    

    The question I have is that there is a TBD which is close to TB.. when the output is TBD  it's using both outputs like this:

     

    TBD image TB image BuccanersD

     

    How can I get around the fact that they are so close?  

     

    Thank you!

  5. Well if you go back up to the top I have set $url to get the 

    'http://www.dallascowboys.com/rss/video',
    'http://www.dallascowboys.com/rss/gallery',
    'http://www.dallascowboys.com/rss/audio',
    'http://espn.go.com/blog/feed?blog=nfceast',
    'https://sports.yahoo.com/nfl/teams/dal/rss.xml',
    

    which comes from:

    
    /********* Feeds *********/
    $urls = array($url);
    /********* Feeds *********/
    

    it should be getting 'filled' from this:

    $url  = $params->get('url');
    

     which is a 'textarea' where users can put their urls like above and populate the array via the $url parameter.. 

     

    It's not reading it for some strange reason... the 

    print_r($url); 
    
    

    was just to see if that $url was catching what was being put in the textarea in the module and it is.... problem is it's not translating later on down in the array() area....

  6. Here is the entire code... I see what you mean...

    JHtml::stylesheet('modules/mod_newsbanner/assets/css/styles.css');
    JHtml::_('jquery.framework');
    JHtml::script(JUri::base() . 'modules/mod_newsbanner/assets/js/tickerme.js');
    $url  = $params->get('url');
     echo '<div id="wrapper" style="margin-top:1px;">';
     echo '<ul id="ticker">';
    
    class Feed_Amalgamator
    {
        public $urls = array();
        public $data = array();
    
        public function addFeeds( array $feeds )
        {
            $this->urls = array_merge( $this->urls, array_values($feeds) );
        }
    
        public function grabRss()
        {
            foreach ( $this->urls as $feed )
            {
                $data = @new SimpleXMLElement( $feed, 0, true );
                if ( !$data )
                    throw new Exception( 'Could not load: ' . $feed );
                foreach ( $data->channel->item as $item )
                {
                    $this->data[] = $item;
                }
            }
        }
    
        public function amalgamate()
        {
            shuffle( $this->data );
            $temp = array();
            foreach ( $this->data as $item )
            {
                if ( !in_array($item->link, $this->links($temp)) )
                {
                    $temp[] = $item;
                }
            }
            $this->data = $temp;
            shuffle( $this->data );
        }
    
        private function links( array $items )
        {
            $links = array();
            foreach ( $items as $item )
            {
                $links[] = $item->link;
            }
            return $links;
        }
    }
    
    /********* Feeds *********/
    $urls = array($url);
    /********* Feeds *********/
    
    try
    {
        $feeds = new Feed_Amalgamator;
        $feeds->addFeeds( $urls );
        $feeds->grabRss();
        $feeds->amalgamate();
    }
    catch ( exception $e )
    {
        die( $e->getMessage() );
    }
    
    foreach ( $feeds->data as $item ) :
    extract( (array) $item );
    
    $truncated = (strlen($description) > 100) ? substr($description, 0, 80) . '...' : $description;
    
    
    
    ?>
    
    <li><img src="modules/mod_newsbanner/assets/images/slogo.jpg" width="19" height="19">   <?php echo $truncated; ?>  <a href="<?php echo $link; ?>" target="_blank"><font color=red>Read More</font></a></li>
    
    <?php endforeach; ?>
    </ul>
      </div>
      
      <script>
    jQuery(function(){
    		jQuery('#ticker').tickerme();
    	});
    </script>
    
  7. When I use the 

    print_r($url);
    
    
    

    it returns

    'http://www.dallascowboys.com/rss/video',
    'http://www.dallascowboys.com/rss/gallery',
    'http://www.dallascowboys.com/rss/audio',
    'http://espn.go.com/blog/feed?blog=nfceast',
    'https://sports.yahoo.com/nfl/teams/dal/rss.xml',<div id="wrapper" style="margin-top:1px;"><ul id="ticker">String could not be parsed as XML
    
  8. Well, first step is figuring out the exact value of $urls...

    print_r($urls);

     

     

    This the output:

    Array
    (
        [0] => http://www.dallascowboys.com/rss/video
        [1] => http://www.dallascowboys.com/rss/gallery
        [2] => http://www.dallascowboys.com/rss/audio
        [3] => http://espn.go.com/blog/feed?blog=nfceast
        [4] => https://sports.yahoo.com/nfl/teams/dal/rss.xml
    ) 
  9. I'm currently parsing multiple rss/xml feeds using this:

    class Feed_Amalgamator
    {
        public $urls = array();
        public $data = array();
    
        public function addFeeds( array $feeds )
        {
            $this->urls = array_merge( $this->urls, array_values($feeds) );
        }
    
        public function grabRss()
        {
            foreach ( $this->urls as $feed )
            {
                $data = @new SimpleXMLElement( $feed, 0, true );
                if ( !$data )
                    throw new Exception( 'Could not load: ' . $feed );
                foreach ( $data->channel->item as $item )
                {
                    $this->data[] = $item;
                }
            }
        }
    
        public function amalgamate()
        {
            shuffle( $this->data );
            $temp = array();
            foreach ( $this->data as $item )
            {
                if ( !in_array($item->link, $this->links($temp)) )
                {
                    $temp[] = $item;
                }
            }
            $this->data = $temp;
            shuffle( $this->data );
        }
    
        private function links( array $items )
        {
            $links = array();
            foreach ( $items as $item )
            {
                $links[] = $item->link;
            }
            return $links;
        }
    }
    
    /********* Feeds *********/
    $urls = array('http://www.dallascowboys.com/rss/video',
    'http://www.dallascowboys.com/rss/gallery',
    'http://www.dallascowboys.com/rss/audio',
    'http://espn.go.com/blog/feed?blog=nfceast',
    'https://sports.yahoo.com/nfl/teams/dal/rss.xml',);
    /********* Feeds *********/
    try
    {
        $feeds = new Feed_Amalgamator;
        $feeds->addFeeds( $urls );
        $feeds->grabRss();
        $feeds->amalgamate();
    }
    catch ( exception $e )
    {
        die( $e->getMessage() );
    }
    
    foreach ( $feeds->data as $item ) :
    extract( (array) $item );
    
    $truncated = (strlen($description) > 100) ? substr($description, 0, 80) . '...' : $description;
    

    and it's working quite nicely... however I'm trying to replace the actual feeds them selves in this section:

    /********* Feeds *********/
    $urls = array('http://www.dallascowboys.com/rss/video',
    'http://www.dallascowboys.com/rss/gallery',
    'http://www.dallascowboys.com/rss/audio',
    'http://espn.go.com/blog/feed?blog=nfceast',
    'https://sports.yahoo.com/nfl/teams/dal/rss.xml',);
    /********* Feeds *********/
    

     with this:

    /********* Feeds *********/
    $urls = array($params->get('url'));
    /********* Feeds *********/
    

    But I keep getting this:

     

    • String could not be parsed as XML

    I know it's reading the links but it doesn't seem to be passing them correctly to be parsed for some reason...

     

    Suggestions?

     

    Thanks in advance!

  10. I'm working on this module and so far so good BUT I would like to be able to highlight the higher score and for some reason I'm having an issue with it...

     

    It's more of an else statement issue...

     

    Here is what I have....

    
    
    if ($game['q'] == 'P') {
    ?>
    <li><div class=box-blue>  <?= $game['d'] ?> | <?= $datey ?> | <?= $game['t'] ?></div>
    
     <?= $homeTeam ?> <?= $game['hs'] ?> <br />
     <?= $visitingTeam ?> <?= $game['vs'] ?>  <br />
          <div class=box-blue>  Game Temp: <?= $current ?>°   Condition: <?= $condition ?> </div></li>
    <?php }
           else { ?>
    <li><?= $homeTeam ?>  <?= $game['hs'] ?> <br /><?= $visitingTeam ?> <?= $game['vs'] ?>  <br />  <div class=box-blue>  <?php if ($game['q'] == "F") {?>Final<?php } ?>
      <?php if ($game['q'] == "FO") {?>Final Overtime<?php }?>
      <?php if ($game['q'] == "H") {?>Half Time<?php }?>
      <?php if ($game['q'] == "1") {?>1st Quarter<?php } ?>
      <?php if ($game['q'] == "2") {?>2nd Quarter<?php } ?>
      <?php if ($game['q'] == "3") {?>3rd Quarter<?php } ?>
      <?php if ($game['q'] == "4") {?>4th Quarter<?php } ?>
      <?php if ($game['q'] == "T") {?>Tie<?php }?>
        <?= $game['k'] ?>
           </div></li>
       <?php }
    
    
     
     
    What I tried to add was this..
       
    If( $game['hs'] > $game['vs'] ){ ?> 
    <li><?= $homeTeam ?>  <font color=red><?= $game['hs'] ?></font> <br /><?= $visitingTeam ?> <?= $game['vs'] ?>  <br />  <div class=box-blue>  <?php if ($game['q'] == "F") {?>Final<?php } 
    
      else {?>
     <li><?= $homeTeam ?>  <?= $game['hs'] ?> <br /><?= $visitingTeam ?> <font color=red><?= $game['vs'] ?></font>  <br />  <div class=box-blue>  <?php if ($game['q'] == "F") {?>Final<?php }  
    
    
    

    But when I do I get an else error... what am I missing here? I thought this would be pretty easy...

    Thank yoU!

  11. You have to index that $phpObj variable like an array, not an object. IE do $phpObj['key'] not $phpObj->key

     

     

     

    WINNER!  Thank you so much... this is what worked :)

     print_r ($phpObj[query][results][channel][image][url]);
    

    Thank you sir!

  12. This is the json data I have and I'm trying to get the info out of it but for some reason I am having great difficulty doing so....

    array(1) {
      ["query"]=>
      array(4) {
        ["count"]=>
        int(1)
        ["created"]=>
        string(20) "2015-12-11T19:32:29Z"
        ["lang"]=>
        string(5) "en-US"
        ["results"]=>
        array(1) {
          ["channel"]=>
          array(13) {
            ["title"]=>
            string(27) "Yahoo! Weather - Elmira, NY"
            ["link"]=>
            string(106) "http://us.rd.yahoo.com/dailynews/rss/weather/Elmira__NY/*http://weather.yahoo.com/forecast/USNY0463_f.html"
            ["description"]=>
            string(29) "Yahoo! Weather for Elmira, NY"
            ["language"]=>
            string(5) "en-us"
            ["lastBuildDate"]=>
            string(28) "Fri, 11 Dec 2015 1:52 pm EST"
            ["ttl"]=>
            string(2) "60"
            ["location"]=>
            array(3) {
              ["city"]=>
              string(6) "Elmira"
              ["country"]=>
              string(13) "United States"
              ["region"]=>
              string(2) "NY"
            }
            ["units"]=>
            array(4) {
              ["distance"]=>
              string(2) "mi"
              ["pressure"]=>
              string(2) "in"
              ["speed"]=>
              string(3) "mph"
              ["temperature"]=>
              string(1) "F"
            }
            ["wind"]=>
            array(3) {
              ["chill"]=>
              string(2) "59"
              ["direction"]=>
              string(3) "230"
              ["speed"]=>
              string(2) "12"
            }
            ["atmosphere"]=>
            array(4) {
              ["humidity"]=>
              string(2) "55"
              ["pressure"]=>
              string(4) "29.8"
              ["rising"]=>
              string(1) "0"
              ["visibility"]=>
              string(2) "10"
            }
            ["astronomy"]=>
            array(2) {
              ["sunrise"]=>
              string(7) "7:24 am"
              ["sunset"]=>
              string(7) "4:34 pm"
            }
            ["image"]=>
            array(5) {
              ["title"]=>
              string(14) "Yahoo! Weather"
              ["width"]=>
              string(3) "142"
              ["height"]=>
              string(2) "18"
              ["link"]=>
              string(24) "http://weather.yahoo.com"
              ["url"]=>
              string(58) "http://l.yimg.com/a/i/brand/purplelogo//uh/us/news-wea.gif"
            }
            ["item"]=>
            array(9) {
              ["title"]=>
              string(40) "Conditions for Elmira, NY at 1:52 pm EST"
              ["lat"]=>
              string(5) "42.09"
              ["long"]=>
              string(6) "-76.81"
              ["link"]=>
              string(106) "http://us.rd.yahoo.com/dailynews/rss/weather/Elmira__NY/*http://weather.yahoo.com/forecast/USNY0463_f.html"
              ["pubDate"]=>
              string(28) "Fri, 11 Dec 2015 1:52 pm EST"
              ["condition"]=>
              array(4) {
                ["code"]=>
                string(2) "34"
                ["date"]=>
                string(28) "Fri, 11 Dec 2015 1:52 pm EST"
                ["temp"]=>
                string(2) "59"
                ["text"]=>
                string(4) "Fair"
              }
    
    

    This is what I have so far but for some reason I cannot seem to get it to work...

    $BASE_URL = "http://query.yahooapis.com/v1/public/yql";
        $yql_query = 'select * from weather.forecast where woeid in (select woeid from geo.places(1) where text="elmira, ny")';
        $yql_query_url = $BASE_URL . "?q=" . urlencode($yql_query) . "&format=json";
        // Make call with cURL
        $session = curl_init($yql_query_url);
        curl_setopt($session, CURLOPT_RETURNTRANSFER,true);
        $json = curl_exec($session);
        // Convert JSON to PHP object
         $phpObj =  json_decode($json, true);
       //  foreach($phpObj['data']['weather'] as $item) {
            echo "<pre>"; var_dump($phpObj);  echo "</pre>";
        //echo $phpObj->results->channel->image->url;
         
    

    I would like to get the image url and have tried several ways but no go...

     

    suggestions?

     

    Thanks in advance! 

     

    John

  13.  

    You can store the data in a text file. You would only perform the curl request if the file does not exists or when a certain time period has passed (eg every 6 hours).  

     

    Example code

    <?php
    
    define('UPDATE_INTERVAL', 60*60*6); // set update interval, eg 6 hours
    define('DATAFILE', 'data.json');    // file to store the data in
    
    $timeSinceUpdated = 0;
    
    // if the datafile exists
    if(file_exists(DATAFILE))
    {
    	// get the time when the datfile was last updated/created
    	$lastModified = filemtime(DATAFILE);
    	// get the time passed since the file has been updated/created
    	$timeSinceUpdated = time() - $lastModified;
    
    	// decode the data from the datafile
    	$data = file_get_contents(DATAFILE);
    	$data = json_decode($data);
    }
    
    // if the file does not exist, or the the update interval has passed
    // perform curl request and update the data
    if(!file_exists(DATAFILE) || $timeSinceUpdated >= UPDATE_INTERVAL)
    {
    	include('simplehtmldom_1_5/simple_html_dom.php');
    	// Create DOM from URL or file
    	$html = file_get_html('http://sportsfeedia.com/nfl/');
    	$curl = curl_init(); 
    	curl_setopt($curl, CURLOPT_URL, $html);  
    	curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);  
    	curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 10);  
    	$str = curl_exec($curl);  
    	curl_close($curl);
    
    	// overwrite the data
    	$data = array();
    	// Find all links, and their text
    	foreach($html->find('a[class=itemtitle]') as $elm)
    	{
    		$link = $elm->href;
       		$text = $elm->plaintext;
       		$news = str_replace("new","*",$text);
    
       		// add new data to array
       		$data[] = array($link, $text, $news);
       	}
    
       	// json encode the data and save to the datafile
       	file_put_contents(DATAFILE, json_encode($data));
    }
    
    // output links
    foreach($data as $contents)
    {
    	list($link, $text, $news) = $contents;
    ?>
    <?= $news ?><BR>
     <a href=<"<?= $link ?>">Read More</a><br>
    <?php
    }
    ?>
    

    WOW.. that was way beyond what I was thinking and probably why I was having such a difficult time with it!!!  Thank you so much!!  

     

    It now loads instantly!!!  Speeds things right up besides not being a jerk and hitting the server each time!!!

     

    It really solved more then 1 problem!  When I was trying to store it it would only store the 1st record NOW it's storing what I want... I will study this because I've run across this issue in other scripts I've tried to write... 

     

    The other was I was trying to write another foreach statement trying to get it to store all the data... NOW it does.  I see what it does here.. gets the info stores it, then opens the file instead of hitting the server for display!  

     

    I was just thinking this morning that there's more then one way to skin a cat... you just showed me I was right!! I guess with programming you limit your mind, you limit your possibilities!! Learning is fun and I really like it... 

     

    NOW I have to learn mysql storage so I can do pagination...  So far everything I've looked at looks difficult because I'm new and security issues are always a concern.

     

    Thank you so very much for your time and patience!!  

  14. include('simple_html_dom.php');
    // Create DOM from URL or file
    $html = file_get_html('http://sportsfeedia.com/nfl/');
    $curl = curl_init(); 
    curl_setopt($curl, CURLOPT_URL, $html);  
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);  
    curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 10);  
    $str = curl_exec($curl);  
    curl_close($curl);
    
    // Find all links, and their text
    foreach($html->find('a[class=itemtitle]') as $elm) {
    	
    	$link=$elm->href;
       $text=$elm->plaintext;
       	$news= str_replace("new","*",$text);
       	
    ?>
    <?= $news ?><BR>
     <a href=<"<?= $link ?>">Read More</a><br>
     
    <?php
     }
    

    That's what I have so far and it's working great... however I've been trying all day to get the contents $link=$elm->href;

    $text=$elm->plaintext;  and json_encode them to data.json so that I don't have to hit the server each time I or a user gets onto the site...

     

    I don't want to be a resource hog here... would like to be a polite about it.   So I can check it 3 to 4 times a day rather then 100 times a day... That's just rude.

     

    So any help would be very much appreciated!!!

     

    Thanks

    John 

  15. 1st question... for some reason I'm throwing a 500 here and can't figure it out... I have double and triple checked all my brackets etc...

    
    $user = JFactory::getUser();
    $u = $user->username;
    	date_default_timezone_set("America/New_York");
    	$d = date("Y-m-d", time());
    
    $xml = simplexml_load_data("modules/mod_holiday/assets/xml/Holidays.xml");
      foreach($xml as $key => $value){
        foreach ($value->events->event as $holiday) {
        
      	  If (($holiday['date']) == $d) { ?>
    	   	
    	   	<div id="CoverPop-cover" class="splash">
            <div class="CoverPop-content splash-center">
            <h2 class="splash-title"><? $holiday['name'] ?> <?= $u ?></h2>
            <p class="splash-intro">This is a test holiday</p>
            <p class="close-splash"><a class="CoverPop-close" href="#">Hit ESC to exit</a></p>
        </div> 
    </div>
     
    <?php 
        } 
       } 
        } ?>
    

    2nd... I"m not sure I'm looping correctly so this is what I'm trying to do...

     

    I'm trying to loop through the entire xml [located below here] and all I am after is the date and name fields... which I thought I was picking up but I could off on my loops...

    Any suggestions would be greatly appreciated..

     

    Thanks

    John

    <events>
    <event>
    <date>2015-02-12</date>
    <name>New Year's Testing</name>
    <flag_day>1</flag_day>
    <url>http://en.wikipedia.org/wiki/New_Year%27s_Day</url>
    <description>New Year's Day is observed on January 1, the first day of the year on the modern Gregorian calendar as well as the Julian calendar used in ancient Rome. With most countries using the Gregorian calendar as their main calendar, New Year's Day is the closest thing to being the world's only truly global public holiday, often celebrated with fireworks at the stroke of midnight as the new year starts. January 1 on the Julian calendar currently corresponds to January 14 on the Gregorian calendar, and it is on that date that followers of some of the Eastern Orthodox churches celebrate the New Year.</description>
    </event>
    <event>
    <date>2015-01-01</date>
    <name>New Year's Day</name>
    <flag_day>1</flag_day>
    <url>http://en.wikipedia.org/wiki/New_Year%27s_Day</url>
    <description>New Year's Day is observed on January 1, the first day of the year on the modern Gregorian calendar as well as the Julian calendar used in ancient Rome. With most countries using the Gregorian calendar as their main calendar, New Year's Day is the closest thing to being the world's only truly global public holiday, often celebrated with fireworks at the stroke of midnight as the new year starts. January 1 on the Julian calendar currently corresponds to January 14 on the Gregorian calendar, and it is on that date that followers of some of the Eastern Orthodox churches celebrate the New Year.</description>
    </event>
    </events>
    
  16. Well if you're doing a foreach loop then tell it to not display for example...

     

    if (!empty($game['vtn']))

     

    That is just an example I used in my module to not display vtn..  I didn't want to display a zero so I used that... 

     

    You can always do a, again not sure if you're looping but if you are I don't know the keys so this is just an example...

    if ($games['vtn'] != "Oklahoma") 
    {
    show your content here... 
    } 

    I'm no expert but that should work....

     

    You're not real specific on whether you don't ever want to show it or just one time... the above method will never show it.

  17. So, I'm a little confused. Here you are looping over $xml->gms->g

    foreach($xml->gms->g as $game) { 
      // if (!empty($game['vtn']))
        {
         $games[(string) $game['gt']][] = $game;
               
        }
     }
    But here (right below it) you are not:
     if (($xml->gms->g['q']) == 'F') {
         $final = 'Final';
     }
     else if (($xml->gms->g['q']) == 'FO') {
         $final = 'Final Overtime';
    }
    You are only comparing the last index of $xml->gms->g (since you just iterated over it), which happens to be "F".

     

    I can't see what you're trying to do with $final, but I think you got some flawed logic in there. :)

     

     

     

    Yeah I do... I'm gonna let it slide for now... 

     

    The first one is looping through...'gt' is game type... WC, CON, DIV, SB, PRO  they are the playoff games... WC = Wildcard..etc...  I did that to put them in the order I wanted them to show..

     

    It would go through and show 2 WC games.. then 2 CON game...then DIV.. Then Pro... Then SB...then back to CON.. then ending at WC

     

    I wanted all the same game types to show at once in the correct order... 

    WC

    DIV

    CON

    PRO

    SB

     

    That is the order they are played in... 

     

    But at the moment I have changed my thinking... Yes I want to show the final or final overtime but that 'q' can also show game quarter 1 2 3 or 4 so I have to set it up for the regular season you know some games are on at 1 some at 4 so that way it will show Final or Final Overtime for finished games and the Quarter they're in for current games....

     

    I'm a bit tired now so I hope I'm not flappin' like a ducks butt right now LOL

  18. Would be really helpful to have the XML as well, or the URL you are retrieving it from... We have nothing to test against without it.

     

    I don't see the code from your first post in the code from your last post, but in the original...the very first line doesn't make sense:

    $f = ($game['q']); {

     

    What's the { for at the end of that line, just before your first if()?

    OH sorry.. sheesh... sometimes I get tunnel vision...

    $type = $params->get('type'); 
     if ($type == '0') {
     	 $url='http://www.nfl.com/liveupdate/scorestrip/ss.xml';
         } 
    else {
        $url='http://www.nfl.com/liveupdate/scorestrip/postseason/ss.xml';     
         }
    

    Right now returns this:

    <ss>
    <gms w="22" y="2014" t="POST" gd="1" bf="0" bph="12">
    <g eid="2015010301" gsis="56492" d="Sat" t="8:15" q="F" htn="Pittsburgh Steelers" hnn="steelers" h="PIT" hs="17" vtn="Baltimore Ravens" vnn="ravens" v="BAL" vs="30" n="NBC" rz="0" ga="" o="1" gt="WC"/>
    <g eid="2015010400" gsis="56493" d="Sun" t="1:05" q="F" htn="Indianapolis Colts" hnn="colts" h="IND" hs="26" vtn="Cincinnati Bengals" vnn="bengals" v="CIN" vs="10" n="CBS" rz="0" ga="" o="2" gt="WC"/>
    <g eid="2015011000" gsis="56495" d="Sat" t="4:35" q="F" htn="New England Patriots" hnn="patriots" h="NE" hs="35" vtn="Baltimore Ravens" vnn="ravens" v="BAL" vs="31" n="NBC" rz="0" ga="" o="3" gt="DIV"/>
    <g eid="2015011101" gsis="56498" d="Sun" t="4:40" q="F" htn="Denver Broncos" hnn="broncos" h="DEN" hs="13" vtn="Indianapolis Colts" vnn="colts" v="IND" vs="24" n="CBS" rz="0" ga="" o="4" gt="DIV"/>
    <g eid="2015011801" gsis="56500" d="Sun" t="6:50" q="F" htn="New England Patriots" hnn="patriots" h="NE" hs="45" vtn="Indianapolis Colts" vnn="colts" v="IND" vs="7" n="CBS" rz="0" ga="" o="5" gt="CON"/>
    <g eid="2015011800" gsis="56499" d="Sun" t="3:05" q="FO" htn="Seattle Seahawks" hnn="seahawks" h="SEA" hs="28" vtn="Green Bay Packers" vnn="packers" v="GB" vs="22" n="FOX" rz="0" ga="" o="6" gt="CON"/>
    <g eid="2015011100" gsis="56497" d="Sun" t="1:05" q="F" htn="Green Bay Packers" hnn="packers" h="GB" hs="26" vtn="Dallas Cowboys" vnn="cowboys" v="DAL" vs="21" n="FOX" rz="0" ga="" o="7" gt="DIV"/>
    <g eid="2015011001" gsis="56496" d="Sat" t="8:15" q="F" htn="Seattle Seahawks" hnn="seahawks" h="SEA" hs="31" vtn="Carolina Panthers" vnn="panthers" v="CAR" vs="17" n="FOX" rz="0" ga="" o="8" gt="DIV"/>
    <g eid="2015010401" gsis="56494" d="Sun" t="4:40" q="F" htn="Dallas Cowboys" hnn="cowboys" h="DAL" hs="24" vtn="Detroit Lions" vnn="lions" v="DET" vs="20" n="FOX" rz="0" ga="" o="9" gt="WC"/>
    <g eid="2015010300" gsis="56491" d="Sat" t="4:35" q="F" htn="Carolina Panthers" hnn="panthers" h="CAR" hs="27" vtn="Arizona Cardinals" vnn="cardinals" v="ARI" vs="16" n="ESPN" rz="0" ga="" o="10" gt="WC"/>
    <g eid="2015012500" gsis="56501" d="Sun" t="8:00" q="F" htn="Team Cris Carter" hnn="team carter" h="CRT" hs="28" vtn="Team Michael Irvin" vnn="team irvin" v="IRV" vs="32" n="ESPN" rz="0" ga="" o="11" gt="PRO"/>
    <g eid="2015020100" gsis="56502" d="Sun" t="6:30" q="F" htn="Seattle Seahawks" hnn="seahawks" h="SEA" hs="24" vtn="New England Patriots" vnn="patriots" v="NE" vs="28" n="NBC" rz="0" ga="" o="12" gt="SB"/>
    </gms>
    
  19.   $ch = curl_init();
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
      curl_setopt($ch, CURLOPT_URL, $url);    // get the url contents
      $data = curl_exec($ch); // execute curl request
      curl_close($ch);
      
      $xml = simplexml_load_string($data);
      $someInt = (int) $xml->gms['w'];
      
     
       
     
      $find = array(
          "ARI",
          "ATL",
          'BAL',
          'BUF',
          'CAR',
          'CHI',
          'CIN',
          'CLE',
          'DAL',
          'DEN',
          'DET',
          'GB',
          'HOU',
          'IND',
          'JAC',
          'KC',
          'MIA',
          'MIN',
          'NE',
          'NO',
          'NYJ',
          'NYG',
          'OAK',
          'PHI',
          'PIT',
          'STL',
          'SD',
          'SF',
          'SEA',
          'TAM',
          'TEN',
          'WAS'
          
      );
      
      $replace = array(
        "Arizona Cardinals", 
        "Atlanta Falcons", 
        'Baltimore Ravens', 
        'Buffalo Bills', 
        'Carolina Panthers', 
      	'Chicago Bears', 
      	'Cincinnati Bengals', 
      	'Cleveland Browns', 
      	'Dallas Cowboys', 
      	'Denver Broncos', 
      	'Detroit Lions', 
      	'Green Bay Packers', 
      	'Houston Texans', 
      	'Indianapolis Colts', 
      	'Jacksonville Jaguars', 
      	'Kansas City Chiefs', 
      	'Miami Dolphins', 
      	'Minnesotta Vikings', 
      	'New England Patriots', 
      	'New Orleans Saints',
      	'New York Jets',
      	'New York Giants', 
      	'Oakland Raiders', 
      	'Philadelphia Eagles', 
      	'Pittsburgh Steelers',
       	'Saint Louis Rams', 
      	'San Diego Chargers', 
      	'San Francisco 49ers', 
      	'Seattle Seahawks', 
      	'Tampa Bay Buccaneers', 
      	'Tennessee Titans', 
      	'Washington Redskins' 
        );
      
     $games = array(
       'REG' => array(),
       'WC' => array(), 
       'DIV' => array(), 
       'CON' => array(),
       'PRO' => array(),
       'SB'  => array() 
       
     );
     
     foreach($xml->gms->g as $game) { 
      // if (!empty($game['vtn']))
        {
         $games[(string) $game['gt']][] = $game;
               
        }
     }
    
     if (($xml->gms->g['q']) == 'F') {
         $final = 'Final';
     }
     else if (($xml->gms->g['q']) == 'FO') {
         $final = 'Final Overtime';
         }
    
    
    	
       
     ?>
    <div class='smarticker6'>
       			<ul>
     
         <?php
         foreach ($games as $gametype => $subgames) {
           foreach ($subgames as $game) {
           	 $date = DateTime::createFromFormat('Ymd', substr($game['eid'], 0, );
             $gdates = $date->format('n/j/Y');
                if ($game['gt'] == 'REG') {
             	$homeTeam = str_replace($find, $replace, $game['h']);
                $visitingTeam = str_replace($find, $replace, $game['v']);
    

    Sure thing.. that's the entire thing :)  

     

    Yeah I figured it was always equal to "Final" but for some reason I've locked it into that and really am confused as to where I went wrong... 

     

    I suppose the smarter thing to do is to just add it to the loop at the end but I'd like it to show "Final" or "Final Overtime" or which Quarter the game is in... then just F or FO or in the case of the quarter it'll just show 1 2 3 or 4.... 

     

    Thanks!

  20. I'm trying to get this to either show "Final" or "Final Overtime" but it just continues to show "Final" even when the XML key value says Overtime...

     

    What am I missing here?

     

    Thank you!

    
    
     
        $f = ($game['q']); {
        if ($f == "1") 
    $f = "1st Quarter";
    else if ($f == "2") 
    $f = "2nd Quarter";
    else if ($f == "3") 
    $f = "3rd Quarter";
    else if ($f == "4") 
    $f = "4th Quarter";
    else if ($f == 'F') 
    $f = "Final";
        else if ($f == 'FO') 
         $f = "Final Overtime"; 
    }
  21. I'm trying to get an element out of an xml file but it keeps returning just 0 and I'm not sure why...

    <g eid="2015010301" gsis="56492" d="Sat" t="8:15" q="F"/>
    

    I'm trying to read the ['g eid'] and print it.    So I'm using this:

    $gdate = (int)$xml->gms['g eid'];
      $arr1 = str_split($gdate);
      print_r($gdate);
    

    I'm using that to see what prints out so I can use it how I need to use it...  when I do it returns this:

     

    Array ( [0] => 0 )

    I'm trying to get it to return the g eid element.

     

    What am I doing wrong here?

     

    Thanks!!!  :happy-04: 

     

     

     

  22. So, the "v" attribute is present in both places with the team abbreviation. So you could do something like this:

    $teams = array(
        'CAR' => 'Carolina Panthers',
        'ARI' => 'Arizona Cardinals',
        'ATL' => 'Atlanta Falcons',
    );
    
    echo $teams[$game['v']];
    If $game['v'] is CAR, then you'll get Carolina Panthers.

     

    OH awesome still being new at this I tend to make it harder then it has to be...LOL  I think we all do that...

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