Jump to content

Using PHP to Input Javascript output to a Table in Mysql database


_I.G.88_

Recommended Posts

Ok here is the perdicment i am in..... i've been working on it for about 3 days now off and on its now 4am in the morning and ive decied i wont sleep till i figure this out..

 

I have a javascript Plugin for Firefox for a game i play that was given to me that Scouts the area and outputs it i need a way to write the PHP code to take the out put of the data and input in to a MYSQL Database Table here is a bit of what the out put looks like i maybe stupid or somthing I dont know!

 

This is the java script output using Firebug on Firefox

<div id="AEinfodiv">
<div>
<div>
<div/>
</div>
</div>
<tbody>
<tr height="30">
<td>
<input type="hidden" value="A38:32:05:20" name="coord0"/>
<a href="map.aspx?loc=A38:32:05:20">
A38:32:05:20 [
<acronym title="Base ID">99443</acronym>
]
</a>
</td>
<td>
- [LUE] Leahcim
<input type="hidden" value="[LUE] Leahcim" name="owner0"/>
</td>
<td>
<input type="hidden" value="" name="occ0"/>
</td>
<td>Defence scouter: Offline </td>
</tr>
<br/>
<tr height="30">
<td>
<input type="hidden" value="A38:32:05:21" name="coord1"/>
<a href="map.aspx?loc=A38:32:05:21">
A38:32:05:21 [
<acronym title="Base ID">140436</acronym>
]
</a>
</td>
<td>
- [(BoC)] Khemnet Mizzrym
<input type="hidden" value="[(BoC)] Khemnet Mizzrym" name="owner1"/>
</td>
<td>
<input type="hidden" value="" name="occ1"/>
</td>
<td>Defence scouter: Offline </td>
</tr>
<br/>
<tr height="30">
<td>
<input type="hidden" value="A38:32:07:30" name="coord2"/>
<a href="map.aspx?loc=A38:32:07:30">
A38:32:07:30 [
<acronym title="Base ID">100965</acronym>
]
</a>
</td>
<td>
- [LUE] Leahcim
<input type="hidden" value="[LUE] Leahcim" name="owner2"/>
</td>
<td>
<input type="hidden" value="" name="occ2"/>
</td>
<td>Defence scouter: Offline </td>
</tr>
<br/>
<tr height="30">
<td>
<input type="hidden" value="A38:32:07:11" name="coord3"/>
<a href="map.aspx?loc=A38:32:07:11">
A38:32:07:11 [
<acronym title="Base ID">140077</acronym>
]
</a>
</td>
<td>
- [TCFS] fI.G.88f
<input type="hidden" value="[TCFS] fI.G.88f" name="owner3"/>
</td>
<td>
<input type="hidden" value="" name="occ3"/>
</td>
<td>Defence scouter: Offline </td>
</tr>
<br/>
<tr height="30">
<td>
<input type="hidden" value="A38:32:07:21" name="coord4"/>
<a href="map.aspx?loc=A38:32:07:21">
A38:32:07:21 [
<acronym title="Base ID">167449</acronym>
]
</a>
</td>
<td>
- [(BoC)] Khemnet Mizzrym
<input type="hidden" value="[(BoC)] Khemnet Mizzrym" name="owner4"/>
</td>
<td>
<input type="hidden" value="" name="occ4"/>
</td>
<td>Defence scouter: Offline </td>
</tr>
<br/>
<tr height="30">
<td>
<input type="hidden" value="A38:32:07:12" name="coord5"/>
<a href="map.aspx?loc=A38:32:07:12">
A38:32:07:12 [
<acronym title="Base ID">241217</acronym>
]
</a>
</td>
<td>
- datdeyboy
<input type="hidden" value="datdeyboy" name="owner5"/>
</td>
<td>
<input type="hidden" value="[sHLD] veso" name="occ5"/>
[
<acronym style="color: red;" title="Occupier">[sHLD] veso</acronym>
]
</td>
<td>Defence scouter: Offline </td>
</tr>
<br/>
<tr height="30">
<td>
<input type="hidden" value="A38:32:16:11" name="coord6"/>
<a href="map.aspx?loc=A38:32:16:11">
A38:32:16:11 [
<acronym title="Base ID">139793</acronym>
]
</a>
</td>
<td>
- [TCFS] fI.G.88f
<input type="hidden" value="[TCFS] fI.G.88f" name="owner6"/>
</td>
<td>
<input type="hidden" value="" name="occ6"/>
</td>
<td>Defence scouter: Offline </td>
</tr>
<br/>
<tr height="30">
<td>
<input type="hidden" value="A38:32:16:31" name="coord7"/>
<a href="map.aspx?loc=A38:32:16:31">
A38:32:16:31 [
<acronym title="Base ID">133847</acronym>
]
</a>
</td>
<td>
- [GBD] CGB ebah gum
<input type="hidden" value="[GBD] CGB ebah gum" name="owner7"/>
</td>
<td>
<input type="hidden" value="" name="occ7"/>
</td>
<td>Defence scouter: Offline </td>
</tr>

 

as you can see number automaticly increment it for the bases and such i also want to make it so if the record already exisist for it to erase that data and input the newest data i feel noobish but i really need help on this one guys anything you can do for me will be much appreiated attached is the javascript which is a Firefox plugin... the Links are incorrect as i am creating my own the guy was kind enough to give me this which was a huge step in the right direction

Sorry for the back to back posts... i think im on to somthing here Not sure just want a second opion.... the Javascript is hosted on mysite and is called up by the Firefox addon so i think this maybe right..... i dont know if ill have to do alot of if there is a way to have it repeat the string for every number automaticly and have it update it's self...

 

 

<?php
// Creates connection to database
$dbhost = 'localhost';
$dbuser = 'user';
$dbpass = 'pass';

$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die                      ('Error connecting to mysql');

$dbname = 'Dbname';
mysql_select_db($dbname);

// update's database with current information???
include 'Scout/aescouter.js';

mysql_select_db($mysql);
$query = "INSERT INTO AEintel (Coord, Owner, occupied by) VALUES ('coord0', 'owner0', 'occ0')";

mysql_query($query) or die('Error, insert query failed');

$query = "FLUSH PRIVILEGES";
mysql_query($query) or die('Error, insert query failed');

mysql_close($con);
?>

 

The only part im iffy on is how it is gonna pull the data off the webpage that the output from the javascript is on :S

I might be able to give you an idea but i am a little rusty on my programing and would have to brush up on it. I am having an issue that you might be able to help with though. My aescouter script stopped working on Sept 12th 08 and i have not idea why.

  • 4 weeks later...

Archived

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

×
×
  • 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.