twittoris Posted September 13, 2010 Share Posted September 13, 2010 I have a table like this: http://empirebuildingsestate.com/company.html How can I separate the table values into variables so I can insert them into my mySQL database? I have been trying DOMDocument but i need some help. Quote Link to comment https://forums.phpfreaks.com/topic/213265-putting-table-into-mysql-table/ Share on other sites More sharing options...
twittoris Posted September 13, 2010 Author Share Posted September 13, 2010 I am thinking something like this. // Create DOMDocument $dom = new DOMDocument(); // Load html string $dom->loadHTML($html2); // Find all links foreach($html2->find('table.tblAddr') as $element) echo $element->table.tblAddr . '<br>'; Quote Link to comment https://forums.phpfreaks.com/topic/213265-putting-table-into-mysql-table/#findComment-1110459 Share on other sites More sharing options...
twittoris Posted September 13, 2010 Author Share Posted September 13, 2010 or something like this? // Get rows from tables $rows = $tables->item(0)->getElementsByTagName('tr'); // Loop over each row foreach ($rows as $row) { Get each column by tag name $cols = $row->getElementsByTagName('td'); Echo values (here you can assign them in array for example) echo $cols->item(0)->nodeValue.'<br />'; echo '<hr />'; i need help Quote Link to comment https://forums.phpfreaks.com/topic/213265-putting-table-into-mysql-table/#findComment-1110471 Share on other sites More sharing options...
PFMaBiSmAd Posted September 13, 2010 Share Posted September 13, 2010 This HTML DOM parser is very easy to use for this type of task - http://sourceforge.net/projects/simplehtmldom/ Quote Link to comment https://forums.phpfreaks.com/topic/213265-putting-table-into-mysql-table/#findComment-1110472 Share on other sites More sharing options...
twittoris Posted September 13, 2010 Author Share Posted September 13, 2010 i dont get how to use a table with it/ Quote Link to comment https://forums.phpfreaks.com/topic/213265-putting-table-into-mysql-table/#findComment-1110477 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.