Re: Fwd: Re: [PHP] Parsing html table into MySQL

From: Date: Fri, 16 Mar 2001 20:29:08 +0000
Subject: Re: Fwd: Re: [PHP] Parsing html table into MySQL
Groups: php.general 
Request: Send a blank email to php-general+get-67527@lists.php.net to get a copy of this message
ok... so the hard way. I'm no regex wizard myself... as a matter of fact I suck at it. I do it the hard (old C like) way. You have to find some chunks of HTML that determine and end of the data in the table and use them to walk trough the doc fetching what you want... let me give an example... <html> <table> <tr><td><font face=arial>Title</font></td><td><font face=arial>Price</font></td></tr> <tr><td><font face=arial>XXX</font></td><td><font face=arial>10.00</font></td></tr> <tr><td><font face=arial>YYY</font></td><td><font face=arial>25.2</font></td></tr> </table> </html> I know that with regex this would be a lot easir but you can do this: $fp=fopen(htmldoc,"r"); while(!feof($fp)) {
        // lets find the first row of DATA (the first were only titles)
        while(!strstr(fgets($fp,256),"</tr>");
        //now we are the first line
        while(!strstr(fgets($fp,256),"</table>")
        {
                // see where I'm getting at?
        }
}
No I need to copy the rows values from HTML table you can see it in exlamle http://66.96.230.191/table.html This is a live score system which updates every 2 min, So I need to get these values and parse it in MySQL after that I neeed to get some element from my database and show in my page.. I have problems in regex I dont know good coding and need only smmall support Please help me :) ----- Original Message ----- From: "Christian Dechery" <cdechery@easynet.com.br> To: "i_union" <i_union@yahoo.com>; "Chris Lambert" <chris@php.net> Cc: <php-general@lists.php.net> Sent: Monday, September 10, 2001 7:57 PM Subject: Re: [PHP] Parsing html table into MySQL
wait a minute... do you want to parse the HTML to get the values to populate a mysql table, or do you have this table in another DB and just want it copied to your mysql one?? If it is the former, you'll some very hardcore regex work to be done... I once did this... it is very stressing work... - you need to analyse the HTML document and find patterns that indicate 'begin of row' 'begin and end of column' and 'end of row', 'end of
table' -
these patterns must be unique or you'll find yourself looking for it indefinetly and going into an endless loop - do a giant loop that only
ends
on 'end of table' and grab the values within this patterns... the code to get this done is huge (not complex), and (I expect) will be only used
once,
right? At 19:25 16/9/2001 +0500, i_union wrote:
I need to get from another page table and put it into MySQL table dynamically for example http://66.96.230.191/table.html so I need to parse this table in database. If you have any code how to implement such operation by using php MySQL please help me; thanks in advance _________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net


« previous php.general (#67527) next »