You’re doing it wrong …
Don’t use a custom table for this!
What you can do instead is store this information in user meta (in the wp_usermeta
table).
Let’s say you want to store last_slide=3
in the user meta table. You’d use the following:
update_user_meta( $user_id, 'last_slide', 3 );
To get this back, you’d call:
get_user_meta( $user_id, 'last_slide', true );
I recommend doing it this way so you don’t try to reinvent the wheel with a custom table and custom queries.
Now to answer the actual question …
In your code, you try to get the value back out of your custom table with this call:
$thenbr = $wpdb->get_row( $wpdb->slideshow( "SELECT * FROM $wpdb->slideshow WHERE user = "admin"" ) );
That basically won’t work. The $wpdb
object has no method called slideshow()
, so calling $wpdb->slideshow()
will throw an error, not return any data. Re-read the Codex article on using this object to select a row.
What you want instead would be along the lines of:
$thenbr = $wpdb->get_row( "SELECT * FROM $wpdb->slideshow WHERE user="admin"" );
But again, I highly advise against using custom queries and custom tables!