WordPress.org

Ready to get started?Download WordPress

Forums

How can I use data from a mysql wordpress data base? (3 posts)

  1. jolona
    Member
    Posted 1 year ago #

    I need to show out of wordpress the title and date from a blog WordPress mysql Data Base. How could I make the request? Could you give me an example?

    I tried to do this but it doesn´t work (it is strange because with andother not-wordpress database it works well):

    <?
    //connect with database
    
    $connect=mysql_connect("localhost","myuser","mypassword");
    
    //select database
    
    mysql_select_db("mydatabase",$connect);
    
    //make querys
    
    $result=mysql_query("select * from wp_posts order by fecha DESC limit 0,20", $connect);
    $totalregistros=mysql_num_rows($result);
    
    //print results in array
    
    while($row=mysql_fetch_array($result))
    {
    echo $row[post_title];
    echo "";
    echo $row[post_date];
    }
    mysql_free_result($result)
    ?>

    Thanks for your answer. I need help!!!

  2. Pioneer Valley Web Design
    Member
    Posted 1 year ago #

    WordPress is attached to a db already, one needs to make queries:

    http://codex.wordpress.org/Class_Reference/wpdb#Run_Any_Query_on_the_Database

  3. jolona
    Member
    Posted 1 year ago #

    Thank you very much for your quick answer.
    I will read it carefully this afternoon.

    Best regards from Spain

Topic Closed

This topic has been closed to new replies.

About this Topic