php - How To Generate An SQL Insert Query From A List Of Values? -
i have long list of values , want insert them database using sql query, writing statement taking long. there way in php, give me ready use insert query list of values provided?
i hereby providing (incomplete)sql query :
insert `aichiwj2_reesk`.`me_skills` (`id`, `skill_name`, `skill_type`, `timestamp`) values (null, 'able listen', 'it', current_timestamp), (null, 'accept feedback', 'it', current_timestamp);`
.....and continues....
hereby providing list of values (i using <li>
view values 1 after other or else, viewing together):
place list of skills inside array, iterate on array , echo sql string browser. it's not fancy, job done.
i rusty in php, i'll not able paste full solution. may work, haven't been able test since don't have machine php right now.
$array = ("skill1", "skill2", "skill3"); $queries_string = "insert `aichiwj2_reesk`.`me_skills` (`id`, `skill_name`, `skill_type`, `timestamp`) values "; ($i = 0; $i < len($array); $i++) $queries_string .= "(null, '"+$array[$i]+"', 'it', current_timestamp), "; echo $queries_string
after prints on screen should replace sinal space , comma ;
sorry can't anymore right now.
Comments
Post a Comment