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

3
  • SELECT player_name FROM myTable?? Commented Jun 10, 2015 at 17:10
  • You might want to investigate how to parse HTML using PHP. Here's an example Q&A. More specifically, here's another Q&A discussing parsing an HTML table. Commented Jun 10, 2015 at 17:11
  • Thank you, I'l check it out Commented Jun 10, 2015 at 18:10

1 Answer 1

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 />";

}

?>
Sign up to request clarification or add additional context in comments.

2 Comments

Just tried the code but it didn't work ?, Just said no for every outcome.
The example worked fine for me, did you set the right file name for the simple html dom include()?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.