Hi,

This mail is very looong as I have included the code.  What I need is to
extract certian text from the html file and dump it into mysql
table.  This is what the html looks like (code below).  The mysql part can
wait now.  I have given comment between each file.  As of now the php is
just printing the html table.  Can someone tell me what next I have to do
or some sample where I can study?

TIA

Adrian

====================================================================
|                       some image not needed                      |
====================================================================
Some text not needed

====================================================================
|Text needed for all records in this table (2nd table              |
====================================================================
|Text   |Text   |Text   |Text   |Text   |Text   |Text   |Text      |
====================================================================
|15/7   |23-28/8|       |Txt    |Txt    |250    |Txt    |Txt       |
|       |       |       |Txt    |Txt    |300    |Txt    |Txt       |
====================================================================

This is the html. The second row in the second table not needed.  The
third row of the second table having the dates will be required for all
records.

========================== HTML =====================================
        <TABLE WIDTH=753 BORDER=0 CELLPADDING=1 CELLSPACING=0>
                <COL WIDTH=574>
                <COL WIDTH=175>
                <TR VALIGN=TOP>
                        <TD WIDTH=574 HEIGHT=4 BGCOLOR="#ffffff">
                                <P><IMG
SRC="sv6326328.gif" NAME="Graphic1" ALIGN=BOTTOM WIDTH=378 HEIGHT=68
BORDER=0></P>
                        </TD>
                        <TD WIDTH=175 BGCOLOR="#000000">
                                <P ALIGN=CENTER
STYLE="margin-bottom: 0in"><FONT FACE="Arial, sans-serif"><FONT SIZE=6
STYLE="font-size: 28pt">Urgent</FONT></FONT></P>
                                <P ALIGN=CENTER><FONT FACE="Arial,
sans-serif"><FONT SIZE=4><B>Fax
                                - Message</B></FONT></FONT></P>
                        </TD>
                </TR>
        </TABLE>
        <P STYLE="margin-bottom: 0in"><BR>
        </P>
        <P ALIGN=CENTER STYLE="margin-bottom: 0in; border: 1.10pt double
#000000; padding: 0.01in">
        <FONT COLOR="#000000"><FONT FACE="Arial, sans-serif"><FONT
SIZE=5><B>OFFRES
        SPECIALES  - 27.06.2001 -  OFFRES SPECIALES
</B></FONT></FONT></FONT>
        </P>
        <P ALIGN=CENTER STYLE="margin-bottom: 0in; border: 1.10pt double
#000000; padding: 0.01in">
        <B><FONT SIZE=3><FONT
FACE="Wingdings">&para;&para;&para;</FONT><FONT FACE="Arial, sans-serif">
        D&eacute;parts de Gen&egrave;ve </FONT><FONT
FACE="Wingdings">&para;&para;&para;</FONT></FONT></B></P>
        <P STYLE="margin-bottom: 0in"><BR>
        </P>
        <P STYLE="margin-bottom: 0in; line-height: 0.17in"><B><FONT
SIZE=3><FONT FACE="Arial, sans-serif">      SOUS
        R&Eacute;SERVE DE MODIFICATION DE PRIX !        Page <SDFIELD
TYPE=PAGE
SUBTYPE=RANDOM FORMAT=PAGE>2</SDFIELD>/6
        </FONT></FONT></B>
        </P>
</DIV>
<P STYLE="margin-right: 0.1in; margin-bottom: 0in"><BR>
</P>
<P STYLE="margin-right: 0.1in; margin-bottom: 0in"><BR>
</P>
<TABLE WIDTH=748 BORDER=1 BORDERCOLOR="#000000" CELLPADDING=1
CELLSPACING=0 RULES=GROUPS>
        <COL WIDTH=86>
        <COL WIDTH=97>
        <COL WIDTH=96>
        <COL WIDTH=244>
        <COL WIDTH=67>
        <COL WIDTH=67>
        <COL WIDTH=76>
        <TBODY>
                <TR>
                        <TD COLSPAN=7 WIDTH=744 HEIGHT=25 VALIGN=TOP>
                                <P><FONT SIZE=4><SUB><B><I>Grand Canarie
(LPA)
</I></B>samedi de
                                Gen&egrave;ve avec LX</SUB></FONT></P>
                        </TD>
                </TR>
        </TBODY>
        <TBODY>
                <TR VALIGN=TOP>
                        <TD WIDTH=86 HEIGHT=18>
                                <P STYLE="margin-top: 0.04in"><FONT
FACE="Arial, sans-serif"><I><B>D&eacute;parts
                                juin</B></I></FONT></P>
                        </TD>
                        <TD WIDTH=97>
                                <P STYLE="margin-top: 0.04in"><FONT
FACE="Arial, sans-serif"><I><B>D&eacute;parts
                                juillet</B></I></FONT></P>
                        </TD>
                        <TD WIDTH=96>
                                <P STYLE="margin-top: 0.04in"><FONT
FACE="Arial, sans-serif"><I><B>D&eacute;parts
                                ao&ucirc;t</B></I></FONT></P>
                        </TD>
                        <TD WIDTH=244>
                                <P STYLE="margin-top: 0.04in"><FONT
FACE="Arial, sans-serif"><I><B>Cat./Logement</B></I></FONT></P>
                        </TD>
                        <TD WIDTH=67>
                                <P STYLE="margin-top: 0.04in"><FONT
FACE="Arial, sans-serif"><I><B>Code
                                htl.</B></I></FONT></P>
                        </TD>
                        <TD WIDTH=67>
                                <P STYLE="margin-top: 0.04in"><FONT
FACE="Arial, sans-serif"><I><B>1
                                sem.</B></I></FONT></P>
                        </TD>
                        <TD WIDTH=76>
                                <P STYLE="margin-top: 0.04in"><FONT
FACE="Arial, sans-serif"><I><B>sem.
                                suppl.</B></I></FONT></P>
                        </TD>
                </TR>
                <TR VALIGN=TOP>
                        <TD WIDTH=86>
                                <P><BR>
                                </P>
                        </TD>
                        <TD WIDTH=97>
                                <P><FONT FACE="Arial,
sans-serif">Sa:   21/28</FONT></P>
                        </TD>
                        <TD WIDTH=96>
                                <P><BR>
                                </P>
                        </TD>
                        <TD WIDTH=244>
                                <P STYLE="margin-bottom: 0in"><FONT
FACE="Arial, sans-serif">LS Apt.
                                Tagoror </FONT><FONT
FACE="Wingdings">ww</FONT><FONT FACE="Arial, sans-serif">
                                </FONT><FONT SIZE=2
STYLE="font-size: 9pt"><FONT FACE="Monotype Sorts">J</FONT></FONT></P>
                                <P><FONT FACE="Arial, sans-serif">LS
Apt. Solymar </FONT><FONT FACE="Wingdings">www</FONT><FONT FACE="Arial,
sans-serif">
                                </FONT><FONT SIZE=2
STYLE="font-size: 9pt"><FONT FACE="Monotype Sorts">J</FONT></FONT></P>
                        </TD>
                        <TD WIDTH=67>
                                <P STYLE="margin-bottom: 0in"><FONT
FACE="Arial, sans-serif">9tagor</FONT></P>
                                <P><FONT FACE="Arial,
sans-serif">9solym</FONT></P>
                        </TD>
                        <TD WIDTH=67>
                                <P STYLE="margin-bottom: 0in"><FONT
FACE="Arial, sans-serif">Fr.
                                        749.-</FONT></P>
                                <P><FONT FACE="Arial,
sans-serif">Fr.   890.-</FONT></P>
                        </TD>
                        <TD WIDTH=76>
                                <P STYLE="margin-bottom: 0in"><FONT
FACE="Arial, sans-serif">Fr.
                                        301.-</FONT></P>

                                <P><FONT FACE="Arial,
sans-serif">Fr.   329.-</FONT></P>
                        </TD>
                </TR>
                <TR VALIGN=TOP>
                        <TD WIDTH=86>
                                <P><BR>
                                </P>
                        </TD>
                        <TD WIDTH=97>
                                <P><BR>
                                </P>
                        </TD>
                        <TD WIDTH=96>
                                <P><FONT FACE="Arial,
sans-serif">Sa:   11</FONT></P>
                        </TD>
                        <TD WIDTH=244>
                                <P STYLE="margin-bottom: 0in"><FONT
FACE="Arial, sans-serif">LS Bung.
                                Colorado Golf </FONT><FONT
FACE="Wingdings">ww<SUP>w</SUP></FONT><FONT SIZE=2
STYLE="font-size: 9pt"><FONT FACE="Monotype Sorts">J</FONT></FONT></P>
                                <P><FONT FACE="Arial, sans-serif">DP
Apt.-Htl. Principado </FONT><FONT FACE="Wingdings">www</FONT><FONT SIZE=2
STYLE="font-size: 9pt"><FONT FACE="Monotype Sorts">J</FONT></FONT></P>
                        </TD>
                        <TD WIDTH=67>
                                <P STYLE="margin-bottom: 0in"><FONT
FACE="Arial, sans-serif">9colgo</FONT></P>
                                <P><FONT FACE="Arial,
sans-serif">9Princi</FONT></P>
                        </TD>
                        <TD WIDTH=67>
                                <P STYLE="margin-bottom: 0in"><FONT
FACE="Arial, sans-serif">Fr.
                                        750.-</FONT></P>
                                <P><FONT FACE="Arial,
sans-serif">Fr.   890.-</FONT></P>
                        </TD>
                        <TD WIDTH=76>
                                <P STYLE="margin-bottom: 0in"><FONT
FACE="Arial, sans-serif">Fr.
                                        301.-</FONT></P>
                                <P><FONT FACE="Arial,
sans-serif">Fr.   350.-</FONT></P>
                        </TD>
                </TR>
                <TR>
                        <TD COLSPAN=7 WIDTH=744 VALIGN=TOP>
                                <P><SPAN STYLE="font-weight: medium"><FONT
FACE="Arial, sans-serif">Suppl&eacute;ment
                                derni&egrave;res places offres speciales
Fr. 100.-      taxes
                                d'a&eacute;roport
Fr. 31.-</FONT></SPAN></P>
                        </TD>
                </TR>
        </TBODY>
</TABLE>
=============================== END HTML ============================

This is the php that I am trying but not getting any where.

=============================== PHP FILE ===========================
<?
$filename = "sample.html";
$fp = fopen($filename, "r");
$html = fread($fp, filesize($filename));
fclose($fp);



preg_match_all("|<TABLE.*>(.*)</table>|Uims", $html, $tables);


$tables = $tables[0];


 for($i = 1, $count = sizeof($tables); $i < $count; ++$i)
{
   preg_match_all("|<TR.*>(.*)</tr>|Uims", $tables[$i], $rows);  // Get a
list ofrows in this table
   $rows = $rows[1];
   //echo "rows $rows[0]";
   for($j = 0, $rowcount = sizeof($rows); $j < $rowcount; ++$j)
   {
      preg_match_all("|<TD.*>(.*)</td>|Uims", $rows[$j], $cells);  // Get
a list of cells in this row
      $cells = $cells[1];
      //echo "cells $cells[0]"; $rows
      for($k = 0, $cellcount = sizeof($cells); $k < $cellcount; ++$k)
      {
         $elements[$i][$j][$k] = $cells[$k];
        if(stristr($elements[$i][$j][$k], "</P>"))
         {      $fields = explode("</P>", $elements[$i][$j][$k]);
                //print_r($fields);
                $num=sizeof($fields);
                //print("$num");
                for($m = 0; $m < ($num-1); $m++)
                {
                //$fields[$m]=strip_tags($fields[$m],"</P>");
                if($fields[$m] != "")

                {
                 if(strstr($fields[$m], '<B>')==0)
                 {

                //strip_tags($fields[$m]);
                print("<br>Feild.$m = $fields[$m]");

                //print("<br>");
               } }
                }
                //print ("One : $fields[0] and Two $fields[1]");
                //print_r($fields);


         }
        // $elements[$i][$j][$k]=strip_tags($elements[$i][$j][$k] =
$cells[$k]);         //$xcells[]=strip_tags($cells[$k]);
      }  //$xcells[]=strip_tags($fields[$k]);
   }
}


============================= END PHP FILE ======================


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to