Jump to content

Extracting data


LincolnC

Recommended Posts

I'm *attempting* to write a script that will take a paste of data from a user and when it's submitted it will drop certain parts of the data into databases and be available for recall later. I have the MySQL sorta out I think but I can't test until I get this part done.

 

Basically people will paste a copied paste (CTRL A, CTRL C and go to my form and just hit CTRL V). It will contain a bunch of data I want to drop in the database but in different areas, like the following example the items in bold are the items I want to grab.

 

First Name: Lincoln

Last Name: Coe

Address: 1234 Easy St, Perfectville, PV 00000

Telephone: 0000000000

Link to comment
https://forums.phpfreaks.com/topic/255341-extracting-data/
Share on other sites

it's not the ideal way of doing it, but you could use:

$array= array();
$string = trim($_POST['yourTextbox']);
$array = explode(":", $string);
$query = "INSERT INTO table (fist, last, address, telephone) VALUES ('{$array[1]}', '{$array[3]}', '{$array[5]}', '{$array[7]}')";
mysql_query($query) or die ("Something went badly wrong!<BR><BR>".mysql_error());

Link to comment
https://forums.phpfreaks.com/topic/255341-extracting-data/#findComment-1309234
Share on other sites

$input = 'First Name: Lincoln
Last Name: Coe
Address: 1234 Easy St, Perfectville, PV 00000
Telephone: 0000000000';

preg_match_all('/^([^:]+):\s*(.+)$/m', $input, $foo);

foreach ( $foo[1] as $k => $label ) {
  echo "The value of {$label} is {$foo[2][$k]} <br />\n";
}

Link to comment
https://forums.phpfreaks.com/topic/255341-extracting-data/#findComment-1309239
Share on other sites

Intrigued (being old and approaching senility), how is the data created on the client side, in this scenario, being sent to the server processing side?

I assume the output (being in label: value syntax) is being generated from another program which cannot be modified to do this post automatically.
Link to comment
https://forums.phpfreaks.com/topic/255341-extracting-data/#findComment-1309245
Share on other sites

No offense, seriously confused here.

1. User on their computer 'cuts/copies' a piece of text (from whatever source and in whatever format).

2. User pastes the text  into a textbox .

3. What action/mechanism is being used by the client side to send the value from the text box (clientside) to the php processing script (server side)?

 

ajax/form/???

 

 

Link to comment
https://forums.phpfreaks.com/topic/255341-extracting-data/#findComment-1309248
Share on other sites

Again, truly no offense.

 

As OP is irregular, and has not shown ANY of his code, we don't know:

 

1. is he using get or post.

2. is user complying with 'cut/paste' OR is user typing in data

3. if user is typing data, is user following the format described (ie the colon)

 

Additionally,

I would think (IMHO) that the OP would be better served if we saw the code OP has tried thus far (both the form and the processing).

 

Link to comment
https://forums.phpfreaks.com/topic/255341-extracting-data/#findComment-1309255
Share on other sites

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.