![]() |
|
[PHP] Extracting data from an html table - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444) +--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151) +---- Forum: Web Development (https://hackforums.net/forumdisplay.php?fid=183) +---- Thread: [PHP] Extracting data from an html table (/showthread.php?tid=5936492) |
Extracting data from an html table - Topkek_Is_Life - Feb 1, 2019 I am trying to convert my html table to a php array. (Table here: http://goldenjoe.xyz/messages/), but I seem to be having a problem. The rows are generated using a json file and the php script reads directly from the index.html on the server, which shows the tbody is empty (because they are generated). php: PHP Code index.html: Code <html>When I run the php I get the error Code Notice: Undefined variable: aDataTableDetailHTML in /home/gueruex/public_html/messages/test2.php on line 26Which makes sense because the variable "aDataTableDetailHTML" is declared in the foreach loop, but that loop isn't running because it does not see any <td> tags in the index.html When you load the actual site up though, the table loads and the <td> tags are present. Spoiler (Click to View) Does anyone here know of a workaround I could use. I've been trying to download the complete webpage and generate a separate html file to use, but wget and curl just download the index.html directly off the server. RE: Extracting data from an html table - +Haze - Feb 1, 2019 You just said you own the website. If that's the case, just create an API that outputs a JSON object and read it that way instead of parsing the HTML table. RE: Extracting data from an html table - Topkek_Is_Life - Feb 1, 2019 Thanks for the suggestion. I decided to do that instead of the html table and everything worked out! RE: Extracting data from an html table - Abruptum - Feb 1, 2019 PHP Code RE: Extracting data from an html table - Squito - Feb 2, 2019 (Feb 1, 2019 01:35 PM)Topkek_Is_Life Wrote: Which makes sense because the variable "aDataTableDetailHTML" is declared in the foreach loop, but that loop isn't running because it does not see any <td> tags in the index.html Because PHP will see the HTML code you posted in OP, not the one you see in the browser, and in that one there is no <td>. |