Jump to content

Copying Data From HTML table Into MySQL


j3rmain3

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
Link to comment
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
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.