I write it means a database converter from dle->wordpress , simple, nyusonli. The question is how to insert this piece of code into the loop so that it pulls out not only the first record in the database, but everything? Do While (?);

 // Коннект к базе DLE $db_dle = mysql_connect("localhost", "vf", ""); mysql_select_db("vf", $db_dle); // Вытаскивание из БД DLE $result_dle = mysql_query("SELECT * FROM dle_post", $db_dle); $array_dle = mysql_fetch_array($result_dle); // Коннект к базе WP $db_wp = mysql_connect("localhost", "social", ""); mysql_select_db("social", $db_wp); // Ввод в БД WP $addpost = mysql_query("INSERT INTO wp_posts (post_author, post_date, post_date_gmt, post_content, post_title, post_status, comment_status, ping_status, post_name, post_parent, menu_order, post_type) VALUES ('1', '$array_dle[date]', '$array_dle[date]', '$array_dle[short_story]', '$array_dle[title]', 'publish', 'open', 'open', '$array_dle[alt_name]', '0', '0', 'post')"); echo $array_dle[title]; echo " - Статья добавлена"; 

    1 answer 1

    Hmm ... Or maybe you do not need to write anything?

     // Коннект к базе DLE $db_dle = mysql_connect("localhost", "vf", ""); mysql_select_db("vf", $db_dle); // Коннект к базе WP $db_wp = mysql_connect("localhost", "social", ""); mysql_select_db("social", $db_wp); // Вытаскивание из БД DLE $result_dle = mysql_query("SELECT * FROM dle_post", $db_dle); while($array_dle = mysql_fetch_array($result_dle)){ // Ввод в БД WP $addpost = mysql_query("INSERT INTO wp_posts (post_author, post_date, post_date_gmt, post_content, post_title, post_status, comment_status, ping_status, post_name, post_parent, menu_order, post_type) VALUES ('1', '$array_dle[date]', '$array_dle[date]', '$array_dle[short_story]', '$array_dle[title]', 'publish', 'open', 'open', '$array_dle[alt_name]', '0', '0', 'post')"); echo $array_dle[title]; echo " - Статья добавлена"; } 
    • And more? What has changed then? It as pulled out / added 1 the first record also also continues to do it - andrewshka
    • oh well, you drew a loop> $ result_dle = mysql_query ("SELECT * FROM dle_post", $ db_dle); while ($ array_dle = mysql_fetch_array ($ result_dle)) {this will output all the records from the database and run them in a loop while they exist, and> $ addpost = mysql_query ("INSERT INTO wp_posts will drive into the system on each pass cycle. @shurik wrote it right. - Ozim
    • Oh, I apologize, did not notice (: I'll check now - andrewshka