Search code examples
phpmysqldocx

php sql:can contents of a word document being split and then insert to database in single row each


sorry for disturbing. I have a table on database call KEYWORDS..contains KEY column..I have a bunch of keywords list in 1 file of docx format called keywords.docx.. each keywords in the file is separated by comma..the keywords will be like this:

environment, country pollution, animal habitat problem, water, energy..

So up there, they are 5 keywords. The idea is I will upload my keywords.docx to the page and then click save button.. in the database server side, the keywords will be automatically insert to the KEY column separately. That means they will have 5 rows of keywords in KEY column under KEYWORDS table. Is it possible in php and mysql..???

Thank you very much for your help and opinion... :)


Solution

  • You can use explode method in PHP somthing like this:-

    <?php $data="ONE TWO THREE FOUR FIVE"; 
    $splittedstring=explode(" ",$data,-2); 
    foreach ($splittedstring as $key => $value) { 
        echo "splittedstring[".$key."] = ".$value."<br>"; } 
    ?> 
    

    its output will be like this:-

    splittedstring[0] = ONE 
    splittedstring[1] = TWO 
    splittedstring[2] = THREE
    

    See more at:

    http://braincybersolutions.com/php-tutorial/php-explode-split-a-string-by-string-into-array/#sthash.tnUaGi9w.dpuf

    After this you can store your values in your database.