0

There is a table on the website Goal.com that I have attached to this question. I want to know how to store the strings in the column Player Name into a variable or database somehow.

The reason for this is because I have a variable in my code called $player. This variable stores a different string every 24 hours and is printed onto my site. This is done by using a custom made function.

I want to code that if '$player' is equal to any string in the column 'Player Name' from goal.com, to re-run the function so a different string is stored in variable and printed on my website.

TABLE : http://www.goal.com/en/scores/transfer-zone?ICID=TZ_DD1_VA

Mackan
  • 6,200
  • 2
  • 25
  • 45
  • `SELECT player_name FROM myTable`?? – AdamMc331 Jun 10 '15 at 17:10
  • You might want to investigate how to parse HTML using PHP. Here's an [example Q&A](http://stackoverflow.com/questions/3577641/how-do-you-parse-and-process-html-xml-in-php). More specifically, here's another [Q&A discussing parsing an HTML table](http://stackoverflow.com/questions/8816194/how-to-parse-html-table-using-php). – lurker Jun 10 '15 at 17:11
  • Thank you, I'l check it out – FutProgrammer Jun 10 '15 at 18:10

1 Answers1

0

PHP Simple HTML DOM Parser can do the job for you. http://simplehtmldom.sourceforge.net/

Download simple_html_dom.php here; http://sourceforge.net/projects/simplehtmldom/files/simple_html_dom.php/download

Here is a full example.

<?php
include("simple_html_dom.php");

libxml_use_internal_errors(true);

$doc = new DOMDocument();
$doc->loadHTMLFile("http://www.goal.com/en/scores/transfer-zone?ICID=TZ_DD1_VA");
$xpath = new DOMXPath($doc);

$player_names = $xpath->query("//td[@class='player_name_col']");

foreach ($player_names as $player_name) {

    echo $player_name->nodeValue . "<br />";

}

?>