Hi I want to get a specific data from a table from an external website. I am not sure how to do that. if step by step provided it will be great. I am the beginner in this.
Thanks in advance…!
Hi I want to get a specific data from a table from an external website. I am not sure how to do that. if step by step provided it will be great. I am the beginner in this.
Thanks in advance…!
Do you have access to the external website’s database?
Thanks for your Reply,
I dont have access to the external website database. But what i thought is I need to read the data , for example which is inside the div content or inside the table td element using class and id from the source of webpage. Is it possible ?
You can try using CURL, or file_get_contents(), then parsing the results to get the information.
I’m also new to PHP and haven’t touched these subject but I’ve managed to create script that will return the the lines that enclosed within
[php]<?php
$file_path = 'http://www.example.com/filepath.php';
$string = file($file_path);
$lines = count($string);
for ($i = 0; $i <= $lines; $i++){
if (isset($string[$i])){
$line = htmlentities($string[$i]) . "<br>";
if (preg_match('/td/', $line)) {
echo $i . " : " . $line;
}
}
}
?>[/php]
I would verify what $string contains, i have a feeling you need to first explode it on new lines (\n for unix, \r\n for windows hosting), then go through the loop.
@Richei. Thanks for the suggestion, but as I said earlier I’m also new to PHP and still haven’t learned many of concepts, but an advice from an experts is worth noting.
The code is working fine on my machine even without explode. ;D
It really depends on the file. If it works, then u learned something