• I’m connecting to a table I made on my wordpress database.
    The tables name is “bookmarks” and it has 4 columns in it titles “id_article” “user_id” “bookmark” and “date added”

    I’m trying to have it so when a specific page loads, it will grab the data from every row that has the logged in Users ID.

    any help, or suggestions would be greatly appreciated.

    <?php
    
    require_once ('wp-config.php');
    
    mysql_select_db ($db, $connection);
    $query = mysql_query('SELECT * FROM bookmarks WHERE user_id = ' . mysql_real_escape ( $_SESSION['user_id'] ) ) or die ( mysql_error () );
    $raw = mysql_fetch_assoc ( $query );
    
    do {
    
    echo $raw['bookmark'] . '<br />';
    
    } while ( $raw = mysql_fetch_assoc ( $query ) );
    
    ?>
Viewing 1 replies (of 1 total)
  • Thread Starter homienick

    (@homienick)

    ok so I’ve learned that I’m already connected to the database throughout the entire page, so I’ve dwindled my code down to this. anyone? much appreciated.

    <?php
    
    $query = mysql_query('SELECT * FROM bookmarks WHERE user_id = ' . mysql_real_escape_string ( $_SESSION['user_id'] ) ) or die ( mysql_error () );
    $raw = mysql_fetch_assoc ( $query );
    
    do {
    
    echo $raw['bookmark'] . '';
    
    } while ( $raw = mysql_fetch_assoc ( $query ) );
    
    ?>
Viewing 1 replies (of 1 total)
  • The topic ‘pull custome tables by user_id, could someone look at this tiny code and help?’ is closed to new replies.