{"id":994,"date":"2014-06-24T10:05:36","date_gmt":"2014-06-24T15:05:36","guid":{"rendered":"http:\/\/xlinesoft.com\/blog\/?p=994"},"modified":"2014-06-26T09:59:00","modified_gmt":"2014-06-26T14:59:00","slug":"displaying-world-cup-2014-data-with-phprunner","status":"publish","type":"post","link":"https:\/\/xlinesoft.com\/blog\/2014\/06\/24\/displaying-world-cup-2014-data-with-phprunner\/","title":{"rendered":"Displaying World Cup 2014 data with PHPRunner."},"content":{"rendered":"<p>This is a just for fun PHPRunner project for all soccer fans out there. Check <a target=_blank href=\"http:\/\/demo.asprunner.net\/volinrok_yahoo_com\/WorldCup2014\/wc2014_matches_list.php?menuItemId=2&#038;show=today\">this live demo<\/a> first.  <\/p>\n<p><a target=_blank href=\"http:\/\/demo.asprunner.net\/volinrok_yahoo_com\/WorldCup2014\/wc2014_matches_list.php?menuItemId=2&#038;show=today\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/xlinesoft.com\/blog\/wp-content\/uploads\/2014\/06\/wc2014-300x187.png\" alt=\"\" title=\"wc2014\" width=\"300\" height=\"187\" class=\"aligncenter size-medium wp-image-995\" srcset=\"https:\/\/xlinesoft.com\/blog\/wp-content\/uploads\/2014\/06\/wc2014-300x187.png 300w, https:\/\/xlinesoft.com\/blog\/wp-content\/uploads\/2014\/06\/wc2014-1024x639.png 1024w, https:\/\/xlinesoft.com\/blog\/wp-content\/uploads\/2014\/06\/wc2014-150x93.png 150w, https:\/\/xlinesoft.com\/blog\/wp-content\/uploads\/2014\/06\/wc2014-400x249.png 400w, https:\/\/xlinesoft.com\/blog\/wp-content\/uploads\/2014\/06\/wc2014.png 1174w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>This project uses live World Cup 2014 data provided by <a target=_blank href=\"http:\/\/worldcup.sfg.io\/\">http:\/\/worldcup.sfg.io\/<\/a> in JSON. PHPRunner project makes the use of this data and if will not work if they website is down for any reason.<\/p>\n<p><!--more--><\/p>\n<h2>Download and setup instructions<\/h2>\n<p>1. This project requires PHPRunner 7.1 (trial or registered) and MySQL database. Run the following script against your MySQL database. The actual data will be coming from <em>worldcup.sfg.io<\/em> but you still need to create this table in your database. <\/p>\n<pre>\r\nCREATE TABLE `wc2014_matches`(`ID` int NOT NULL AUTO_INCREMENT, `team1` varchar(50) NULL, `team2` varchar(50) NULL, `datetime` datetime NULL, `match_number` int NULL, `location` varchar(50) NULL, `team1_goals` int NULL, `team2_goals` int NULL, `team1_code` varchar(10) NOT NULL, `team2_code` varchar(10) NULL, `status` varchar(50) NULL, PRIMARY KEY (`ID`))CHARACTER SET utf8;\r\nINSERT INTO `wc2014_matches` (`ID`,`team1`,`team2`,`datetime`,`match_number`,`location`,`team1_goals`,`team2_goals`,`team1_code`,`team2_code`,`status`) VALUES (1,' ',' ',NULL,NULL,NULL,NULL,NULL,'',NULL,NULL);\r\n\r\n<\/pre>\n<p>2. <a href=\"http:\/\/asprunner.com\/files\/misc\/WorldCup2014.zip\">Download PHPRunner project<\/a>, unzip it somewhere on your local machine and open it in PHPRunner 7.1.<\/p>\n<p>3. Change the database connection to point it to your database. <\/p>\n<p>4. Change output folder location (&#8216;Output directory&#8217; screen).<\/p>\n<p>5. Build, view in web browser and enjoy. To reduce the number requests to <em>worldcup.sfg.io<\/em> we cache JSON data in session variables. <\/p>\n<h2>A few notes on project setup<\/h2>\n<p>1. Data is not coming from the database but from a third party website in JSON format. If you ever wondered how PHPRunner can consume data from third party web services check this project events.<\/p>\n<ul>\n<li>AfterAppInit &#8211; this where we retrieve, parse data and store it in session variables for later use<\/li>\n<li>List page: Custom Query &#8211; this is where we prepare an array with results to be displayed. See how URL parameters like <em>show=today<\/em> or <em>show=tomorrow<\/em> are handled<\/li>\n<li>List page: After record processed &#8211; here we change the background color of today&#8217;s matches<\/li>\n<li>List page: Javascript OnLoad event &#8211; here we make the whole row on the list page clickable pointing itto the View page<\/li>\n<li>View page: Process record values &#8211; here we retrieve one record from our array of matches based on match number passed via URL.<\/li>\n<\/ul>\n<p>2. Check the use of Google Fonts like &#8216;Open Sans&#8217;. <\/p>\n<ul>\n<li>\nIn the HEAD sectipn of your page (Visual Editor in HTML mode) add the following line:<\/p>\n<pre>\r\n&lt;LINK href=\"http:\/\/fonts.googleapis.com\/css?family=Open+Sans\" \r\nrel=\"stylesheet\" type=\"text\/css\">\r\n<\/pre>\n<\/li>\n<li>\nThen in Custom CSS you can use something like this:<\/p>\n<pre>\r\n.body {\r\nfont-family: 'Open Sans',sans-serif;\r\n}\r\n<\/pre>\n<\/li>\n<\/ul>\n<p>Feel free to ask your questions in comments<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This is a just for fun PHPRunner project for all soccer fans out there. Check this live demo first. This project uses live World Cup 2014 data provided by http:\/\/worldcup.sfg.io\/ in JSON. PHPRunner project makes the use of this data and if will not work if they website is down for any reason.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1,8],"tags":[],"class_list":["post-994","post","type-post","status-publish","format-standard","hentry","category-php-category","category-tutorials"],"_links":{"self":[{"href":"https:\/\/xlinesoft.com\/blog\/wp-json\/wp\/v2\/posts\/994","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/xlinesoft.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/xlinesoft.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/xlinesoft.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/xlinesoft.com\/blog\/wp-json\/wp\/v2\/comments?post=994"}],"version-history":[{"count":11,"href":"https:\/\/xlinesoft.com\/blog\/wp-json\/wp\/v2\/posts\/994\/revisions"}],"predecessor-version":[{"id":1006,"href":"https:\/\/xlinesoft.com\/blog\/wp-json\/wp\/v2\/posts\/994\/revisions\/1006"}],"wp:attachment":[{"href":"https:\/\/xlinesoft.com\/blog\/wp-json\/wp\/v2\/media?parent=994"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/xlinesoft.com\/blog\/wp-json\/wp\/v2\/categories?post=994"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/xlinesoft.com\/blog\/wp-json\/wp\/v2\/tags?post=994"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}