Jump to content

mojomystery

New Members
  • Posts

    6
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

mojomystery's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. @DavidAM, This works perfectly. Thanks! - dan -
  2. I've seen similar solutions offered as to what I'm looking for but this is a slight twist that I need help with. In a mySQL table, I have a "time" (not timestamp) value. Example : 18:00:00 Unfortunately I don't have have date values to show which date this time was from. Here's what I want to do. Here's some sample data to work with: Current Time - 14:00 Time value # 1 from a mySQL query - 18:00:00 Time value # 2 from a mySQL query - 13:00:00 In PHP, I want to assume that, any time in the future is actually from the previous day. I then want to calculate the difference in time between the current time and any time value I pull from a query.and store that in a variable. For example, using time value #1 from above, the difference would be 20:00:00 (since it was 20 hours ago). Using time value #2, the difference would be 1:00:00 (only 1 hour). It sounds simple but I might be over analyzing my problem to figure this out. Thanks for any help offered - dan -
  3. @Barand, Thank you very much. I think this produces exactly what I need. In my first test, however, I noticed that this company's XML file is prone to bad formatting which breaks the query. For example, their latest version contains this: <unit> <iterator>35</iterator> <route>80</route> <rt_name>'Louisa'</rt_name> <name>173</name> <lat>2900</lat> <lng>-9000</lng> <bearing>-1</bearing> <car_type>'RTA Buses'</car_type> <speed>-1</speed> <GMT/>[/size][/font][/color] </unit> Notice how they are missing a <GMT>? This breaks the query and it won't execute when it hits that line. Is there any way to account for mistakes like this so it doesn't break? Thanks again for your help and sorry for the delay in responding. Today is the first day I've been able to get back to working on this. - dan -
  4. First, thanks in advance for any help. Here's my issue. I've read through tons of similar problems here but I don't think I'm understanding this enough to make this work. I have an XML file such as: <unitlist> <unit> <iterator>0</iterator> <route>2</route> <rt_name>'Riverfront Streetcar'</rt_name> <name>457</name> <lat>2956.21014</lat> <lng>-9004.62839</lng> <bearing>2.14501</bearing> <car_type>'RTA Street Cars'</car_type> <speed>16.57122</speed> <GMT>043432</GMT>[/indent] </unit> <unit> <iterator>1</iterator> <route>10</route> <rt_name>'Tchoupitoulas'</rt_name> <name>250</name> <lat>2958.0927</lat> <lng>-9005.28724</lng> <bearing>1.532399</bearing> <car_type>'RTA Buses'</car_type> <speed>0.6904677</speed> <GMT>104620</GMT>[/indent] </unit> </unitlist> What I want to do is, for each <unit>, import all attributes of that unit (iterator,route,rt_name, etc, etc, etc) into my mySQL database. My problem is that, all it's doing is importing the same attributes of the first <unit> the number of times that <unit> exists. In this example, it's importing the same information from the first <unit> twice, as two records/rows. If I had 90 <unit>s, it would import 90 identical records. Here's my code: foreach($unitlist->unit as $unit) { //insert into database mysql_query("INSERT INTO businfo (iterator,route,rt_name,name,lat,lng,bearing,car_type,speed,GMT)VALUES (\"$iterator\",\"$route\", \"$rt_name\", \"$name\", \"$lat\", \"$lng\", \"$bearing\", \"$car_type\", \"$speed\", \"$GMT\")") or die(mysql_error()); } Can anyone explain what I'm doing wrong? Thanks again for the help! - dan -
  5. Every once in a while I come across a php page and would love to learn the code behind it. Unfortunately, however, since it's run server-side, I can never see the actual code (only the resulting HTML). Is there some hidden way of seeing the actual php used on website? TIA...
×
×
  • 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.