Html to database: retain special character (mathematical symbols)
Results 1 to 5 of 5

Thread: Html to database: retain special character (mathematical symbols)

  1. #1
    Member
    Join Date
    Jul 2002
    Posts
    38

    Html to database: retain special character (mathematical symbols)

    Dear Sir

    I have an excel file having data with special characters (algebra question answers)

    The original data is in an excel file
    it has subscript, superscript and many mathematical symbols and characters like
    ∴,≅⊥∫∪∴≈≡⊆μ and many

    I am using CuteEditor for editing data.
    The data from excel can be cut and pasted in this and you get complete excel sheet in html table format.

    Same is listed below

    I want to separate and store

    each row of (this html table) and store it in separate rows of database table and each column (of this html table) will be stored in separate column of database table

    Data stored
    HTML Code:
    <table border="1" cellpadding="0" cellspacing="0" width="728" style="border-collapse: collapse; width: 728px;" bordercolor="">  <colgroup><col width="36" style="width:27pt">  <col width="47" style="width:35pt">  <col width="285" style="width:214pt">  <col width="272" style="width:204pt">  <col width="24" style="width:18pt">  <col width="64" style="width:48pt">  </colgroup><tbody>
    
    <tr height="17" style="height:12.75pt">   <td height="17" align="right" width="36" style="height:12.75pt;width:27pt">3002</td>   <td align="left" width="47" style="width:35pt">Given:</td>   <td align="left" width="285" style="width:214pt">Equation of the graph is 2x + y   + 1 = 0&nbsp;</td>   <td width="272" style="width:204pt"></td>   <td colspan="2" align="left" width="88" style="width:66pt">AS1</td>  </tr> 
    
    <tr height="17" style="height:12.75pt">   <td height="17" style="height:12.75pt"></td>   <td align="left">To Find:</td>   <td align="left">Co-ordinates of 3 points on the graph</td>   <td></td>   <td colspan="2" align="left">AS2</td>  </tr>  
    
    <tr height="17" style="height:12.75pt">   <td height="17" style="height:12.75pt"></td>   <td align="left">Solution:</td>   <td align="left">2x + y + 1 = 0&nbsp;</td>   <td></td>   <td colspan="2" align="left">AS3</td>  </tr>  <tr height="17" style="height:12.75pt">   <td height="17" style="height:12.75pt"></td>   <td></td>   <td align="left">∴ y = - 2x - 1</td>   <td align="left">rearranging the terms</td>   <td colspan="2" align="left">AS4</td>  </tr>  
    
    <tr height="17" style="height:12.75pt">   <td height="17" style="height:12.75pt"></td>   <td></td>   <td align="left">When x = 1</td>   <td></td>   <td colspan="2" align="left">AS5</td>  </tr>  <tr height="17" style="height:12.75pt">   <td height="17" style="height:12.75pt"></td>   <td></td>   <td align="left">y = - 2(1)&nbsp; -1&nbsp;</td>   <td align="left">substituting x = 1</td>   <td colspan="2" align="left">AS6</td>  </tr> 
    
     <tr height="17" style="height:12.75pt">   <td height="17" style="height:12.75pt"></td>   <td></td>   <td align="left">∴ y = -2 - 1</td>   <td></td>   <td colspan="2" align="left">AS7</td>  </tr>  <tr height="17" style="height:12.75pt">   <td height="17" style="height:12.75pt"></td>   <td></td>   <td align="left">∴ y = -3&nbsp;</td>   <td></td>   <td colspan="2" align="left">AS8</td>  </tr> 
    
     <tr height="17" style="height:12.75pt">   <td height="17" style="height:12.75pt"></td>   <td></td>   <td align="left">∴ A(1, -3) is a point on the graph</td>   <td></td>   <td colspan="2" align="left">AS9</td>  </tr>  <tr height="17" style="height:12.75pt">   <td height="17" style="height:12.75pt"></td>   <td></td>   <td align="left">When x = 2</td>   <td></td>   <td colspan="2" align="left">AS10</td>  </tr>  <tr height="17" style="height:12.75pt">   <td height="17" style="height:12.75pt"></td>   <td></td>   <td align="left">y = - 2(2)&nbsp; -1&nbsp;</td>   <td align="left">substituting x = 2</td>   <td colspan="2" align="left">AS11</td>  </tr> 
    
     <tr height="17" style="height:12.75pt">   <td height="17" style="height:12.75pt"></td>   <td></td>   <td align="left">∴ y = -4 - 1</td>   <td></td>   <td colspan="2" align="left">AS12</td>  </tr>  <tr height="17" style="height:12.75pt">   <td height="17" style="height:12.75pt"></td>   <td></td>   <td align="left">∴ y = -5</td>   <td></td>   <td colspan="2" align="left">AS13</td>  </tr> 
     <tr height="17" style="height:12.75pt">   <td height="17" style="height:12.75pt"></td>   <td></td>   <td align="left">∴ B(2, -5) is a point on the graph</td>   <td></td>   <td colspan="2" align="left">AS14</td>  </tr>  <tr height="17" style="height:12.75pt">   <td height="17" style="height:12.75pt"></td>   <td></td>   <td align="left">When x = 3</td>   <td></td>   <td colspan="2" align="left">AS15</td>  </tr> 
     <tr height="17" style="height:12.75pt">   <td height="17" style="height:12.75pt"></td>   <td></td>   <td align="left">y = - 2(3)&nbsp; -1&nbsp;</td>   <td align="left">substituting x = 3</td>   <td colspan="2" align="left">AS16</td>  </tr>  <tr height="17" style="height:12.75pt">   <td height="17" style="height:12.75pt"></td>   <td></td>   <td align="left">∴ y = -6 - 1</td>   <td></td>   <td colspan="2" align="left">AS17</td>  </tr>  
    
    <tr height="17" style="height:12.75pt">   <td height="17" style="height:12.75pt"></td>   <td></td>   <td align="left">∴ y = -7</td>   <td></td>   <td colspan="2" align="left">AS18</td>  </tr>  <tr height="17" style="height:12.75pt">   <td height="17" style="height:12.75pt"></td>   <td></td>   <td align="left">∴ C(1, -3) is a point on the graph</td>   <td></td>   <td colspan="2" align="left">AS19</td>  </tr>  
    
    <tr height="17" style="height:12.75pt">   <td height="17" style="height:12.75pt"></td>   <td align="left">Ans:</td>   <td align="left">A(1, -3), B(2, -5), C(1, -3) are the three points&nbsp;</td>   <td></td>   <td colspan="2" align="left">AS20</td>  </tr>
    </tbody>
    </table><br /><div id="LCS_336D0C35_8A85_403a_B9D2_65C292C39087_communicationDiv"></div>
    I want to store each row (of table ) in separate row of database table
    Attached Images Attached Images

  2. #2
    Senior Member
    Join Date
    Apr 2003
    Location
    Silver Lake
    Posts
    4,830
    You haven't described any problem?

    Also, I have never heard of CuteEditor.
    IMPORTANT: STOP using the mysql extension. Use mysqli or pdo instead.
    World War One happened 100 years ago. Visit Old Grey Horror for the agony and irony.

  3. #3
    Pna lbh ernq guvf¿
    Join Date
    Jul 2004
    Location
    Kansas City area
    Posts
    19,395
    If you're asking a general "How would you do this?" question, my first thought would be: Can you get the data in a better format? For example, would it not be possible to get it in CSV form?

    If not, then PHP can certainly work with HTML documents - see the manual for the DOM extensions (though you might want to start with some tutorials first). You could use it to traverse each row in the table and extract the relevant information (perhaps by first examining the "colspan" attribute(s), if applicable).

  4. #4
    Member
    Join Date
    Jul 2002
    Posts
    38

    narrow down the problem

    In string given below

    <tr height="19" style="height:14.25pt">

    how to trim this to <tr>

  5. #5
    Senior Member
    Join Date
    Apr 2003
    Location
    Silver Lake
    Posts
    4,830
    this will trim any <tr> tag down to just that -- <tr> no spaces or anything
    PHP Code:
    $str "<tr height=\"19\" style=\"height:14.25pt\">";
    $clean_str preg_replace('/<tr[^>]*>/i''<tr>'$str); 
    IMPORTANT: STOP using the mysql extension. Use mysqli or pdo instead.
    World War One happened 100 years ago. Visit Old Grey Horror for the agony and irony.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •