944,148 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 2326
  • PHP RSS
You are currently viewing page 1 of this multi-page discussion thread
Oct 3rd, 2007
0

Parse html

Expand Post »
Hi all.

I have an application were a user fitt (outside the game) a "ship" and after the full fitt he can save that in a doc file.

In that file we'll see 4 fields with vari lines in each of them (not the same fitt for all the ships).

I want to create a form where you paste the entire content of the file and submit. That will be placed in mysql database. There is a page were the users can search a ship and he will see all the fittings availble for the ship he selected on a webpage.

Can anyone help me get this thing going ?

Would be much apriciated if someone could help me.

Example of the file:

Item 1 Low Slot
Item 2 Low Slot
Item 3 Low Slot

Item 1 Med Slot
Item 2 Med Slot
Item 3 Med Slot
Item 4 Med Slot

Item 1 High Slot
Item 2 High Slot
Item 3 High Slot
Item 4 High Slot
Item 5 High Slot

Item 1 Rig Slot
Item 2 Rig Slot
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
ramirez is offline Offline
6 posts
since Oct 2007
Oct 5th, 2007
0

Re: Parse html

i think i can help you, but please explain it in more detail. what is a "fitt", maybe fitting i don't know. just please be more clear. what exactly are you trying to do or what are you even saying, "fitt", "full fitt", ????????
Reputation Points: 235
Solved Threads: 193
Nearly a Posting Virtuoso
kkeith29 is offline Offline
1,315 posts
since Jun 2007
Oct 5th, 2007
0

Re: Parse html

Hi Keith

Fitt is for "Fitting".

I play a game were we have ships and need to br fitted with some equipment.
We have a 3party tool that give us the possibility to "test" some fittings (when you drag the modules into the shipp it gives the stats of battle and ship endurance).

After fitting you can copy the fitting and paste were ever you want.
I would like to make a page so the members of my corp can share some info.

1 - They would paste the info in some kind of form and when submited it drops the info in a mysql;
2 - In a search page they will get a result according to their needs.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
ramirez is offline Offline
6 posts
since Oct 2007
Oct 5th, 2007
0

Re: Parse html

all of that is not hard, and will only take maybe an hour. what i need from you: mysql table name, fields of that table. Also, what exactly are they going to be putting into the database. just show an example thats all i need.
Reputation Points: 235
Solved Threads: 193
Nearly a Posting Virtuoso
kkeith29 is offline Offline
1,315 posts
since Jun 2007
Oct 5th, 2007
0

Re: Parse html

Medium Armor Repairer II
Reactor Control Unit II
Power Diagnostic System II
Adaptive Nano Plating II
Reactor Control Unit II

Cap Recharger II
Cap Recharger II
Cap Recharger II

Medium Nosferatu II
Medium Nosferatu II
Medium Nosferatu II
Medium Nosferatu II

Anti-Thermic Pump II
Anti-Kinetic Pump II

_____________________

This is one example of a fitting created in the program. This is what I'v got to copy/paste.
The first 5 lines represent the low-slot of the ship, the next 3 the mid-slot, the other 4 are the high-slot and the last 2 are the rig-slot.
The number of lines per slot are diferent from ship to ship.

The user should copy the file (like the one above) and paste it to a form, he also need to give a name to the fitting (on another field).

The field of the table should be something like:

ID;
Ship; (this one the real name of the ship from the game)
Fitting;
Date; (optional)
Reputation Points: 10
Solved Threads: 0
Newbie Poster
ramirez is offline Offline
6 posts
since Oct 2007
Oct 6th, 2007
0

Re: Parse html

All this is, is basic parsing of information and separating it into their relevant fields. What don't you get?
Last edited by iamthwee; Oct 6th, 2007 at 9:07 am.
Featured Poster
Reputation Points: 1536
Solved Threads: 431
Posting Expert
iamthwee is offline Offline
5,865 posts
since Aug 2005
Oct 6th, 2007
0

Re: Parse html

Click to Expand / Collapse  Quote originally posted by iamthwee ...
All this is, is basic parsing of information and separating it into their relevant fields. What don't you get?
I know that is just parsing. The problem is that the text don't have fixed fields.
The text change from fitting to fitting, ex:

Fitting 1:

Medium Armor Repairer II
Reactor Control Unit II
Power Diagnostic System II

Cap Recharger II
Cap Recharger II

Medium Nosferatu II
Medium Nosferatu II
Medium Nosferatu II

[empty rig slot]

Fitting 2:

Medium Armor Repairer II
1600mm Reinforced Titanium Plates I
Energized Basic Adaptive Nano Plating
Magnetic Field Stabilizer II
Partial Power Plant Manager: Capacity Power Relay
Type-D Power Core Modification: Capacitor Power Relay

Heavy Capacitor Booster II
Sensor Booster II
Magnetic Scattering Amplifier II
100MN Afterburner II

[empty high slot]
Neutron Blaster Cannon II
Neutron Blaster Cannon II
Neutron Blaster Cannon II
Neutron Blaster Cannon II
Neutron Blaster Cannon II

[empty rig slot]
[empty rig slot]

As you can see I have here 2 diferent fittings for 2 diferent ships. How can I parse this?
Reputation Points: 10
Solved Threads: 0
Newbie Poster
ramirez is offline Offline
6 posts
since Oct 2007
Oct 7th, 2007
0

Re: Parse html

What you'd have to do is make sure the patterns exist for each input file (they don't have to be strict patterns, just a standard format) and then parse your files off of that. If you don't have any patterns to match, you've got a situation where you're trying to do human-level comprehension. That's way beyond the average PHP program.
Reputation Points: 23
Solved Threads: 23
Posting Pro in Training
Puckdropper is offline Offline
494 posts
since Jul 2004
Oct 7th, 2007
0

Re: Parse html

As you can see in my last post, none of the previous texts had a fixed line.
Each line represents a item and each blank line represents a change in the type of slot used.

I know that this is difficult to do. My hope was that I could parse the text to use a DB, that I have, of the items.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
ramirez is offline Offline
6 posts
since Oct 2007
Oct 7th, 2007
0

Re: Parse html

Take a moment and look at what will always be the same in your file.
1. Are the "fittings" from a standard set?
2. Is each blank line guaranteed to be there?
2a. What about line endings? (Does an EOL mean end of item slot?)
3. Can "fittings" go in a different place on your "vessel" or are they one position only?
3a. If they can go multiple places, does the order of the list matter?
Reputation Points: 23
Solved Threads: 23
Posting Pro in Training
Puckdropper is offline Offline
494 posts
since Jul 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: Need Help with converting an ID to a Name
Next Thread in PHP Forum Timeline: preg_replace





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC