Jump to content

split 1 mysqlfield to many other fields , delimmited


mybestshot

Recommended Posts

I got in table A  1 field : *hc-v3.6,GPS,A,N,47"07'21.8,E,015"12'36.1,000.0,129.1,00*

need to put this in another table called B

fieldname

firmware:*hc-v3.6

What:GPS

Location:A

latitude:N,47"07'21.8

longitude:E,015"12'36.1

speed:000.0

direction:129.1

ab:00*

 

How can i do this ?

Link to comment
Share on other sites

Here's how I do a similar thing but there may be better ways if anyone can suggest them?

 

Get the field into a variable.  Have you got a DB query set up?

 

field = $ORIG_DATA

$DATA=(explode(",",$ORIG_DATA));    //Splits it into an array $DATA on the ',' delimiter

 

I assign a named variable cos I find it easier when troubleshooting but you don't have to.  You could just use $DATA[n].

 

$Firmware = ($DATA[0]);

$GPS= ($DATA[1]);

$Location = ($DATA[2]);

$Latitude = ($DATA[3]);

$Longitude = ($DATA[4]);

$Speed = ($DATA[5]);

$direction = ($DATA[6]);

$ab = ($DATA[7]);

 

You then simply use the $Firmware, $GPS etc wherever you need them.

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.