Jump to content

Archived

This topic is now archived and is closed to further replies.

j3rmain3

Copying Data From HTML table Into MySQL

Recommended Posts

I have a table which has been setup in HTML, but now i need to store a rating system for the documents. I really do not want to copy all the data and enter it into mysql manually because there are about 50 documents. Is there a way i could place the data from the html table into mysql by using variables or something like that?

Here is some sample coding incase someone will need coding to work with

[size=9pt]Table Coding[/size]

[code]

echo "<tr>";
echo "<td>Players Name</td>";
echo "<td>Position</td>";
echo "<td>Goals</td>";
echo "</tr>";

echo "<tr>";
echo "<td>Jeremy Beadle</td>";
echo "<td>Striker</td>";
echo "<td>15</td>";
echo "</tr>";

[/code]

[size=9pt]php[/size]

[code]

mysql_connect(****,****,****) or die ("ERROR:".mysql_error());
mysql_select_db(****) or die ("ERROR."mysql_error());

$query = "INSERT INTO ( This is where i have no idea what to write to import the data from the exisiting data in the html table into mySQL db )";

[/code]

The table has already been setup in mysql. All i need to do is copy the info across.

If more coding is need, just send a reply

thanks
j3rmain3

Share this post


Link to post
Share on other sites
It can be done by using fopen() on the html files and then using preg_match() or preg_match_all() or something similar to extract the data.

You'd need to read up on the preg_* functions first.

If someone else has a better idea, I'm sure they'll post it soon.  Maybe something XML related.

Regards
Huggie

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.