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 </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 </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) -1 </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 </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) -1 </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) -1 </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 </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
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).
Bookmarks