Jump to content

Insert in a DB


pacome

Recommended Posts

Just because somebody doesn't answer you in an hour doesn't mean they don't know. You have to give people some time.

 

Anyway, I believe it would be possible with COM, however that requires your web server to be Windows, and then you have to learn proper COM usage, which is a whole other can of worms.

 

All in all, I don't think it'd be worth the time to write a page to do it.

 

Anybody else know if it's possible without COM?

Link to comment
Share on other sites

You might try saving into a csv file and importing from that. I did this kind of thing for an address book I made for my wife. I exported the windows address book into a csv file and then have a script to grab the csv and import it properly.

 

This will take a csv file with the first row being the column names, and puts it into an associative array. You will have to modify it to your needs as it simply prints out the array in the end, but its a pretty neat script.

 

<?php
$file=your_csv_file_here;
//Move through a CSV file, and output an associative array for each line
ini_set("auto_detect_line_endings", 1);
$current_row = 1;
$handle = fopen("$file", "r");
while ( ($data = fgetcsv($handle, 10000, ",") ) !== FALSE )
{
   $number_of_fields = count($data);
   if ($current_row == 1)
   {
   //Header line
       for ($c=0; $c < $number_of_fields; $c++)
       {
           $header_array[$c] = $data[$c];
       }
   }
   else
   {
   //Data line
       for ($c=0; $c < $number_of_fields; $c++)
       {
           $data_array[$header_array[$c]] = $data[$c];
       }
        print_r($data_array);

   }
   $current_row++;
}
fclose($handle);
};
?>

 

I did not write this, I found it in the php manual under the comments in the fgetcsv function(I think). Thanks to the person who wrote this though.

Link to comment
Share on other sites

Hopefully the post by chronister will work for you.

 

If not I have had good luck extracting data from Word if it's in a column by using this command to exctract the column from word: Place the cursor in the upper left of the first column and then press the Shift and Alt keys together and drag to highlight your column. Cut and paste into notepad and insert the textfile into the respective field... repeat the process a few times.

 

Another tip for data if it is in a table is to cut and paste the table into notepad, all formatting will be lost and the data should be intact. You might have to use a search & replace function to place delimiters between fields.

 

best  :)

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.