homepage Welcome to WebmasterWorld Guest from 54.227.182.191
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Subscribe to WebmasterWorld

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Need help getting array into mysql
Somewhat complicated help needed
whitecoder




msg:4502006
 2:20 pm on Sep 30, 2012 (gmt 0)

Hello all, I have somewhat a complicated question and hopefully someone can provide me with a solution or atleast get me in the right direction.

I have a xml file that I wrote a function for to get it into a php array, now I am stumped as what I need to do to get this array into a MySQL database. I am a fairly decent programmer but array's are not my strong point whatsoever and I have no problem letting everybody know that up front.

Here's the array that my function is putting out...I guess the biggest problem I think I have is certain aspects of the xml file will change depending on how many users are there what happens, penalties, etc, and I don't know how to handle this to get it into a database correctly each time.

Array
(
[@attributes] => Array
(
[version] => 1.0
)

[RaceResults] => Array
(
[Setting] => Race Weekend
[PlayerFile] => Brandon Elder
[DateTime] => 1349010847
[TimeString] => 2012/09/30 09:14:07
[Mod] => F1RFT_2010_MP.rfm
[Season] => Array
(
)

[TrackVenue] => .: F1RFT 2010 Tracks :.
[TrackCourse] => 2010 Brasil wet GP
[TrackEvent] => RFT 2010/18 Brasil Wet
[TrackLength] => 4262.2
[GameVersion] => 1.255
[Dedicated] => 0
[ConnectionType] => Custom
[RaceLaps] => 5
[RaceTime] => 0
[MechFailRate] => 2
[DamageMult] => 25
[FuelMult] => 1
[TireMult] => 1
[VehiclesAllowed] => 2010F1RFT
[ParcFerme] => 3
[FixedSetups] => 0
[FreeSettings] => 11
[FixedUpgrades] => 0
[Race] => Array
(
[DateTime] => 1349011040
[TimeString] => 2012/09/30 09:17:20
[Laps] => 5
[Minutes] => 0
[Stream] => Array
(
[Incident] => Array
(
[0] => Nico Hulkenberg(5) reported contact (0.03) with another vehicle Adrian Sutil(2)
[1] => Sebastian Vettel(9) reported contact (0.32) with another vehicle Felipe Massa(1)
[2] => Rubens Barrichello(4) reported contact (0.10) with another vehicle Nico Hulkenberg(5)
[3] => Rubens Barrichello(4) reported contact (0.06) with another vehicle Nico Hulkenberg(5)
[4] => Sebastian Vettel(9) reported contact (0.39) with another vehicle Rubens Barrichello(4)
[5] => Nico Rosberg(3) reported contact (0.13) with another vehicle Robert Kubica(6)
[6] => Nico Rosberg(3) reported contact (0.32) with another vehicle Robert Kubica(6)
[7] => Rubens Barrichello(4) reported contact (0.68) with another vehicle Mark Webber(8)
[8] => Felipe Massa(1) reported contact (0.10) with another vehicle Mark Webber(8)
[9] => Rubens Barrichello(4) reported contact (0.10) with another vehicle Felipe Massa(1)
[10] => Rubens Barrichello(4) reported contact (0.35) with another vehicle Mark Webber(8)
[11] => Sebastian Vettel(9) reported contact (0.52) with another vehicle Mark Webber(8)
[12] => Sebastian Vettel(9) reported contact (0.26) with another vehicle Mark Webber(8)
[13] => Nico Rosberg(3) reported contact (0.61) with another vehicle Rubens Barrichello(4)
[14] => Lucas di Grassi(7) reported contact (0.42) with Immovable
[15] => Lucas di Grassi(7) reported contact (0.23) with Immovable
[16] => Nico Hulkenberg(5) reported contact (0.61) with Immovable
[17] => Nico Hulkenberg(5) reported contact (0.06) with Immovable
[18] => Nico Hulkenberg(5) reported contact (0.16) with Immovable
[19] => Lucas di Grassi(7) reported contact (0.16) with Immovable
[20] => Robert Kubica(6) reported contact (0.13) with Immovable
[21] => Robert Kubica(6) reported contact (0.16) with Immovable
)

[Score] => Array
(
[0] => Mark Webber(8) lap=0 point=1 t=28.947 et=40.215
[1] => Sebastian Vettel(9) lap=0 point=1 t=29.520 et=40.787
[2] => Nico Rosberg(3) lap=0 point=1 t=30.216 et=41.483
[3] => Robert Kubica(6) lap=0 point=1 t=30.360 et=41.628
[4] => Adrian Sutil(2) lap=0 point=1 t=31.060 et=42.328
[5] => Felipe Massa(1) lap=0 point=1 t=31.185 et=42.453
[6] => Lucas di Grassi(7) lap=0 point=1 t=31.568 et=42.835
[7] => Nico Hulkenberg(5) lap=0 point=1 t=31.760 et=43.028
[8] => Rubens Barrichello(4) lap=0 point=1 t=32.019 et=43.287
[9] => Mark Webber(8) lap=0 point=2 t=80.668 et=91.936
[10] => Nico Rosberg(3) lap=0 point=2 t=83.385 et=94.653
[11] => Robert Kubica(6) lap=0 point=2 t=84.811 et=96.078
[12] => Adrian Sutil(2) lap=0 point=2 t=85.160 et=96.428
[13] => Felipe Massa(1) lap=0 point=2 t=86.110 et=97.378
[14] => Rubens Barrichello(4) lap=0 point=2 t=87.635 et=98.903
[15] => Sebastian Vettel(9) lap=0 point=2 t=87.639 et=98.907
[16] => Nico Hulkenberg(5) lap=0 point=2 t=87.960 et=99.228
[17] => Mark Webber(8) lap=1 point=0 t=101.513 et=112.781
[18] => Nico Rosberg(3) lap=1 point=0 t=104.969 et=116.237
[19] => Robert Kubica(6) lap=1 point=0 t=106.225 et=117.492
[20] => Adrian Sutil(2) lap=1 point=0 t=106.385 et=117.653
[21] => Felipe Massa(1) lap=1 point=0 t=107.563 et=118.830
[22] => Rubens Barrichello(4) lap=1 point=0 t=109.149 et=120.417
[23] => Sebastian Vettel(9) lap=1 point=0 t=109.494 et=120.762
[24] => Nico Hulkenberg(5) lap=1 point=0 t=109.687 et=120.954
[25] => Mark Webber(8) lap=1 point=1 t=22.922 et=135.703
[26] => Nico Rosberg(3) lap=1 point=1 t=23.191 et=139.428
[27] => Robert Kubica(6) lap=1 point=1 t=23.435 et=140.928
[28] => Adrian Sutil(2) lap=1 point=1 t=24.105 et=141.758
[29] => Felipe Massa(1) lap=1 point=1 t=23.404 et=142.235
[30] => Rubens Barrichello(4) lap=1 point=1 t=23.611 et=144.028
[31] => Sebastian Vettel(9) lap=1 point=1 t=23.666 et=144.428
[32] => Nico Hulkenberg(5) lap=1 point=1 t=23.924 et=144.878
[33] => Lucas di Grassi(7) lap=0 point=2 t=144.238 et=155.505
[34] => Lucas di Grassi(7) lap=1 point=0 t=165.285 et=176.553
[35] => Mark Webber(8) lap=1 point=2 t=75.372 et=188.153
[36] => Nico Rosberg(3) lap=1 point=2 t=74.967 et=191.204
[37] => Robert Kubica(6) lap=1 point=2 t=75.985 et=193.478
[38] => Felipe Massa(1) lap=1 point=2 t=80.122 et=198.953
[39] => Lucas di Grassi(7) lap=1 point=1 t=22.856 et=199.409
[40] => Nico Hulkenberg(5) lap=1 point=2 t=79.824 et=200.778
[41] => Mark Webber(8) lap=2 point=0 t=96.202 et=208.983
[42] => Nico Rosberg(3) lap=2 point=0 t=96.145 et=212.382
[43] => Robert Kubica(6) lap=2 point=0 t=97.166 et=214.659
[44] => Felipe Massa(1) lap=2 point=0 t=101.872 et=220.703
[45] => Nico Hulkenberg(5) lap=2 point=0 t=101.255 et=222.210
[46] => Sebastian Vettel(9) lap=1 point=2 t=103.241 et=224.003
[47] => Mark Webber(8) lap=2 point=1 t=23.020 et=232.003
[48] => Nico Rosberg(3) lap=2 point=1 t=22.824 et=235.205
[49] => Robert Kubica(6) lap=2 point=1 t=22.676 et=237.335
[50] => Felipe Massa(1) lap=2 point=1 t=22.710 et=243.413
[51] => Sebastian Vettel(9) lap=2 point=0 t=124.416 et=245.178
[52] => Nico Hulkenberg(5) lap=2 point=1 t=23.622 et=245.832
[53] => Lucas di Grassi(7) lap=1 point=2 t=76.875 et=253.428
[54] => Rubens Barrichello(4) lap=1 point=2 t=143.791 et=264.208
[55] => Adrian Sutil(2) lap=1 point=2 t=150.100 et=267.753
[56] => Sebastian Vettel(9) lap=2 point=1 t=22.650 et=267.828
[57] => Lucas di Grassi(7) lap=2 point=0 t=98.450 et=275.003
[58] => Mark Webber(8) lap=2 point=2 t=75.545 et=284.528
[59] => Rubens Barrichello(4) lap=2 point=0 t=164.926 et=285.342
[60] => Adrian Sutil(2) lap=2 point=0 t=171.282 et=288.934
[61] => Robert Kubica(6) lap=2 point=2 t=76.819 et=291.478
[62] => Nico Rosberg(3) lap=2 point=2 t=80.375 et=292.757
[63] => Felipe Massa(1) lap=2 point=2 t=74.850 et=295.553
[64] => Lucas di Grassi(7) lap=2 point=1 t=22.950 et=297.953
[65] => Mark Webber(8) lap=3 point=0 t=96.395 et=305.378
[66] => Rubens Barrichello(4) lap=2 point=1 t=22.695 et=308.038
[67] => Adrian Sutil(2) lap=2 point=1 t=22.746 et=311.680
[68] => Robert Kubica(6) lap=3 point=0 t=98.070 et=312.729
[69] => Nico Rosberg(3) lap=3 point=0 t=101.699 et=314.081
[70] => Felipe Massa(1) lap=3 point=0 t=96.175 et=316.878
[71] => Mark Webber(8) lap=3 point=1 t=23.175 et=328.553
[72] => Robert Kubica(6) lap=3 point=1 t=22.902 et=335.630
[73] => Nico Rosberg(3) lap=3 point=1 t=22.797 et=336.878
[74] => Felipe Massa(1) lap=3 point=1 t=22.854 et=339.732
[75] => Lucas di Grassi(7) lap=2 point=2 t=77.075 et=352.078
[76] => Nico Hulkenberg(5) lap=2 point=2 t=130.819 et=353.029
[77] => Adrian Sutil(2) lap=2 point=2 t=75.795 et=364.729
[78] => Lucas di Grassi(7) lap=3 point=0 t=98.459 et=373.462
[79] => Nico Hulkenberg(5) lap=3 point=0 t=152.003 et=374.212
[80] => Mark Webber(8) lap=3 point=2 t=76.200 et=381.578
[81] => Adrian Sutil(2) lap=3 point=0 t=96.995 et=385.929
[82] => Robert Kubica(6) lap=3 point=2 t=79.049 et=391.778
[83] => Rubens Barrichello(4) lap=2 point=2 t=108.360 et=393.703
[84] => Felipe Massa(1) lap=3 point=2 t=77.150 et=394.028
[85] => Lucas di Grassi(7) lap=3 point=1 t=24.022 et=397.484
[86] => Nico Hulkenberg(5) lap=3 point=1 t=23.790 et=398.003
[87] => Mark Webber(8) lap=4 point=0 t=97.111 et=402.489
[88] => Sebastian Vettel(9) lap=2 point=2 t=159.100 et=404.278
[89] => Nico Rosberg(3) lap=3 point=2 t=90.997 et=405.078
[90] => Adrian Sutil(2) lap=3 point=1 t=22.824 et=408.753
[91] => Robert Kubica(6) lap=4 point=0 t=100.833 et=413.561
[92] => Rubens Barrichello(4) lap=3 point=0 t=130.219 et=415.561
[93] => Felipe Massa(1) lap=4 point=0 t=99.006 et=415.884
[94] => Mark Webber(8) lap=4 point=1 t=23.169 et=425.658
[95] => Sebastian Vettel(9) lap=3 point=0 t=180.507 et=425.685
[96] => Nico Rosberg(3) lap=4 point=0 t=112.339 et=426.419
[97] => Robert Kubica(6) lap=4 point=1 t=22.919 et=436.480
[98] => Rubens Barrichello(4) lap=3 point=1 t=22.877 et=438.438
[99] => Felipe Massa(1) lap=4 point=1 t=23.058 et=438.942
[100] => Sebastian Vettel(9) lap=3 point=1 t=22.922 et=448.607
[101] => Nico Rosberg(3) lap=4 point=1 t=22.797 et=449.216
[102] => Lucas di Grassi(7) lap=3 point=2 t=79.941 et=453.403
[103] => Nico Hulkenberg(5) lap=3 point=2 t=79.665 et=453.878
[104] => Adrian Sutil(2) lap=3 point=2 t=75.383 et=461.312
[105] => Lucas di Grassi(7) lap=4 point=0 t=102.221 et=475.683
[106] => Nico Hulkenberg(5) lap=4 point=0 t=101.520 et=475.732
[107] => Adrian Sutil(2) lap=4 point=0 t=96.674 et=482.603
[108] => Robert Kubica(6) lap=4 point=2 t=75.841 et=489.403
[109] => Felipe Massa(1) lap=4 point=2 t=79.571 et=495.455
[110] => Sebastian Vettel(9) lap=3 point=2 t=80.318 et=506.003
[111] => Checkered for Robert Kubica, laps=5/5, endET=510.583710/306254101833471170000000000000000000000.000000, crossedAfterTime=0
[112] => Robert Kubica(6) lap=5 point=0 t=97.022 et=510.584
[113] => Mark Webber(8) lap=4 point=2 t=108.089 et=510.578
[114] => Felipe Massa(1) lap=5 point=0 t=101.419 et=517.303
[115] => Sebastian Vettel(9) lap=4 point=0 t=101.651 et=527.336
[116] => Mark Webber(8) lap=5 point=0 t=129.397 et=531.886
[117] => Nico Rosberg(3) lap=4 point=2 t=134.958 et=561.378
)

)

[MostLapsCompleted] => 5
[Driver] => Array
(
[0] => Array
(
[Name] => Nico Rosberg
[Connected] => 1
[VehFile] => F1RFT_04.VEH
[UpgradeCode] => 00000000 00000000
[VehName] => 2. Nico Rosberg
[CarType] => Season 2010
[CarClass] => Season 2010
[CarNumber] => 04
[TeamName] => Mercedes GP
[isPlayer] => 0
[GridPos] => 4
[Position] => 4
[ClassGridPos] => 4
[ClassPosition] => 4
[Points] => 9
[ClassPoints] => 9
[LapRankIncludingDiscos] => 1
[Lap] => Array
(
[0] => 104.9692
[1] => 96.1448
[2] => 101.6991
[3] => 112.3387
)

[BestLapTime] => 96.1448
[Laps] => 4
[Pitstops] => 0
[FinishStatus] => None
[ControlAndAids] => AIControl
)

[1] => Array
(
[Name] => Felipe Massa
[Connected] => 1
[VehFile] => F1RFT_07.VEH
[UpgradeCode] => 00000000 00000000
[VehName] => 1. Felipe Massa
[CarType] => Season 2010
[CarClass] => Season 2010
[CarNumber] => 07
[TeamName] => Scuderia Ferrari
[isPlayer] => 0
[GridPos] => 5
[Position] => 2
[ClassGridPos] => 5
[ClassPosition] => 2
[Points] => 13
[ClassPoints] => 13
[LapRankIncludingDiscos] => 2
[Lap] => Array
(
[0] => 107.5627
[1] => 101.8725
[2] => 96.1750
[3] => 99.0064
[4] => 101.4186
)

[BestLapTime] => 96.1750
[FinishTime] => 506.0352
[Laps] => 5
[Pitstops] => 0
[FinishStatus] => Finished Normally
[ControlAndAids] => AIControl
)

[2] => Array
(
[Name] => Mark Webber
[Connected] => 1
[VehFile] => F1RFT_06.VEH
[UpgradeCode] => 00000000 00000000
[VehName] => 2. Mark Webber
[CarType] => Season 2010
[CarClass] => Season 2010
[CarNumber] => 06
[TeamName] => RBR-Renault
[isPlayer] => 0
[GridPos] => 2
[Position] => 3
[ClassGridPos] => 2
[ClassPosition] => 3
[Points] => 11
[ClassPoints] => 11
[LapRankIncludingDiscos] => 3
[Lap] => Array
(
[0] => 101.5132
[1] => 96.2021
[2] => 96.3949
[3] => 97.1108
[4] => 129.3970
)

[BestLapTime] => 96.2021
[FinishTime] => 520.6181
[Laps] => 5
[Pitstops] => 0
[FinishStatus] => Finished Normally
[ControlAndAids] => AIControl
)

[3] => Array
(
[Name] => Adrian Sutil
[Connected] => 1
[VehFile] => F1RFT_14.VEH
[UpgradeCode] => 00000000 00000000
[VehName] => 1. Adrian Sutil
[CarType] => Season 2010
[CarClass] => Season 2010
[CarNumber] => 14
[TeamName] => Force India-Mercedes
[isPlayer] => 0
[GridPos] => 6
[Position] => 7
[ClassGridPos] => 6
[ClassPosition] => 7
[Points] => 6
[ClassPoints] => 6
[LapRankIncludingDiscos] => 4
[Lap] => Array
(
[0] => 106.3852
[1] => 171.2816
[2] => 96.9947
[3] => 96.6737
)

[BestLapTime] => 96.6737
[Laps] => 4
[Pitstops] => 0
[FinishStatus] => DNF
[DNFReason] => Engine
[ControlAndAids] => AIControl
)

[4] => Array
(
[Name] => Robert Kubica
[Connected] => 1
[VehFile] => F1RFT_11.VEH
[UpgradeCode] => 00000000 00000000
[VehName] => 1. Robert Kubica
[CarType] => Season 2010
[CarClass] => Season 2010
[CarNumber] => 11
[TeamName] => Renault
[isPlayer] => 0
[GridPos] => 3
[Position] => 1
[ClassGridPos] => 3
[ClassPosition] => 1
[Points] => 15
[ClassPoints] => 15
[LapRankIncludingDiscos] => 5
[Lap] => Array
(
[0] => 106.2247
[1] => 97.1664
[2] => 98.0699
[3] => 100.8327
[4] => 97.0224
)

[BestLapTime] => 97.0224
[FinishTime] => 499.3162
[Laps] => 5
[Pitstops] => 0
[FinishStatus] => Finished Normally
[ControlAndAids] => AIControl
)

[5] => Array
(
[Name] => Lucas di Grassi
[Connected] => 1
[VehFile] => F1RFT_25.VEH
[UpgradeCode] => 00000000 00000000
[VehName] => 2. Lucas di Grassi
[CarType] => Season 2010
[CarClass] => Season 2010
[CarNumber] => 25
[TeamName] => Virgin Racing
[isPlayer] => 0
[GridPos] => 8
[Position] => 6
[ClassGridPos] => 8
[ClassPosition] => 6
[Points] => 7
[ClassPoints] => 7
[LapRankIncludingDiscos] => 6
[Lap] => Array
(
[0] => 165.2852
[1] => 98.4500
[2] => 98.4594
[3] => 102.2213
)

[BestLapTime] => 98.4500
[Laps] => 4
[Pitstops] => 0
[FinishStatus] => DNF
[DNFReason] => Engine
[ControlAndAids] => AIControl
)

[6] => Array
(
[Name] => Nico Hulkenberg
[Connected] => 1
[VehFile] => F1RFT_10.VEH
[UpgradeCode] => 00000000 00000000
[VehName] => 2. Nico Hulkenberg
[CarType] => Season 2010
[CarClass] => Season 2010
[CarNumber] => 10
[TeamName] => Williams
[isPlayer] => 0
[GridPos] => 9
[Position] => 5
[ClassGridPos] => 9
[ClassPosition] => 5
[Points] => 8
[ClassPoints] => 8
[LapRankIncludingDiscos] => 7
[Lap] => Array
(
[0] => 109.6866
[1] => 101.2554
[2] => 152.0027
[3] => 101.5199
)

[BestLapTime] => 101.2554
[Laps] => 4
[Pitstops] => 0
[FinishStatus] => DNF
[DNFReason] => Engine
[ControlAndAids] => AIControl
)

[7] => Array
(
[Name] => Sebastian Vettel
[Connected] => 1
[VehFile] => F1RFT_05.VEH
[UpgradeCode] => 00000000 00000000
[VehName] => 1. Sebastian Vettel
[CarType] => Season 2010
[CarClass] => Season 2010
[CarNumber] => 05
[TeamName] => RBR-Renault
[isPlayer] => 0
[GridPos] => 1
[Position] => 8
[ClassGridPos] => 1
[ClassPosition] => 8
[Points] => 5
[ClassPoints] => 5
[LapRankIncludingDiscos] => 8
[Lap] => Array
(
[0] => 109.4940
[1] => 124.4162
[2] => 180.5069
[3] => 101.6510
)

[BestLapTime] => 101.6510
[FinishTime] => 516.0682
[Laps] => 4
[Pitstops] => 0
[FinishStatus] => Finished Normally
[ControlAndAids] => AIControl
)

[8] => Array
(
[Name] => Rubens Barrichello
[Connected] => 1
[VehFile] => F1RFT_09.VEH
[UpgradeCode] => 00000000 00000000
[VehName] => 1. Rubens Barrichello
[CarType] => Season 2010
[CarClass] => Season 2010
[CarNumber] => 09
[TeamName] => Williams
[isPlayer] => 0
[GridPos] => 7
[Position] => 9
[ClassGridPos] => 7
[ClassPosition] => 9
[Points] => 4
[ClassPoints] => 4
[LapRankIncludingDiscos] => 9
[Lap] => Array
(
[0] => 109.1494
[1] => 164.9256
[2] => 130.2186
)

[BestLapTime] => 109.1494
[Laps] => 3
[Pitstops] => 0
[FinishStatus] => DNF
[DNFReason] => Engine
[ControlAndAids] => AIControl
)

[9] => Array
(
[Name] => Brandon Elder
[Connected] => 1
[VehFile] => F1RFT_18.VEH
[UpgradeCode] => 00000000 00000000
[VehName] => 1. Jarno Trulli
[CarType] => Season 2010
[CarClass] => Season 2010
[CarNumber] => 18
[TeamName] => Lotus Racing
[isPlayer] => 1
[GridPos] => 10
[Position] => 10
[ClassGridPos] => 10
[ClassPosition] => 10
[Points] => 0
[ClassPoints] => 0
[LapRankIncludingDiscos] => 10
[Laps] => 0
[Pitstops] => 0
[FinishStatus] => DNF
[DNFReason] => Engine
)

)

)

)

)

 

swa66




msg:4502015
 3:07 pm on Sep 30, 2012 (gmt 0)

What you need to do is to create a database model (something you can do with paper and pencil)

This is for this sample you gave here non trivial to do.

You have al least teams, car, drivers, tracks, raceresults, starting grids, incidents, etc. and it all can evolve through the season and over different seasons.

Next you find the relations between them (e.g. an incident is between two cars), and what are the attributes , ...

If you've never done this, I'd suggest an easier start where all this is more clearly defined to learn things before you tackle this one.

Once you have the model on poaper, you can create tables in a database and start to populate them.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved