spires Posted March 14, 2008 Share Posted March 14, 2008 Hi Guys. Can anyone help me with uploading an array to MYSQL. Example: the array: array 1 array 2 array 3 Database: id - 1 - array 1 id - 2 - array 2 id - 3 - array 3 basically, each row of the array, creats a new row in the database. Here is my code <?php $keywords = stripslashes($_POST['keywords']); $keyword_array = explode("\n", $keywords); $ext_keywords = stripslashes($_POST['ext_keywords']); $ext_keyword_array = explode("\n", $ext_keywords); foreach ($keyword_array as $keyword) { foreach ($ext_keyword_array as $ext_keyword) { $keyword = trim($keyword); $ext_keyword = trim($ext_keyword); $key .= $keyword.' '.$ext_keyword; while ($key){ $sql = "INSERT INTO adwords_list (key, value, both) VALUES ('$keyword', '$ext_keyword', '$key')"; $query = mysql_query($sql) or die (mysql_error()); } } } ?> Thanks for any help Link to comment https://forums.phpfreaks.com/topic/96191-uploading-to-mysql/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.