Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $dbname = 'mydb';
- $dbhost = 'myhost';
- $dbuser = 'myuser';
- $dbpass = 'mypass';
- $conn = mysqli_connect($dbhost, $dbuser, $dbpass, $dbname);
- if (!$conn){
- die("could not connect " . mysqli_connect_errno() . mysqli_connect_error());
- }
- $qry = "SELECT name, date, artist, owner, style FROM paintings";
- $result = mysqli_query($conn, $qry);
- $posts_array = array();
- if ($result->num_rows > 0){
- while($row = mysqli_fetch_array($result)){
- global $user_ID;
- $new_post = array(
- 'post_title' => $row['name'],
- 'post_content' => 'Artist: '.$row['artist'].'  Style: '.$row['style'].'  Date: '.$row['date'].'    Images:     Documents:',
- 'post_author' => $user_ID,
- 'post_type' => 'pages',
- );
- $posts_array[]=$new_post;
- }
- } else {
- echo "no resulting rows";
- }
- mysqli_close($conn);
- foreach ( $posts_array as $post) {
- $post_id = wp_insert_post($post);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement