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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.