WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] getting current post title from database (3 posts)

  1. mattskills
    Member
    Posted 2 years ago #

    Hi,

    I am trying to query a table using the post title of the current post. the dj username will be the same as the post title, Can anybody help me with the right query to make $username = the current post title.

    <?php
    	$username = !!!!!!!!!!!!!!!
    $data = mysql_query("SELECT * FROM users WHERE username='$username'")
    or die(mysql_error());
     while($info = mysql_fetch_array( $data ))
    
     print "".$info['djbio'] . "";
    
    ?>

    Thanks,
    Matt

  2. vtxyzzy
    Member
    Posted 2 years ago #

    If the code you showed is inside the Loop, this should work:

    $username = $post->post_title;

  3. mattskills
    Member
    Posted 2 years ago #

    That worked , Thanks :)

Topic Closed

This topic has been closed to new replies.

About this Topic