Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
|
I suppose your users have to log in your system at a moment.
You probably have something in a session that reflect this.
What you need, is to know which id they have on your system.
If I suppose that you would store the twitter name in the same tbale as the user informations, it would be:
PHP Code:
$q="select twitterName from users where userId={$_SESSION['userId']}"; $r=mysql_query($r); $twitterUser=NULL; while($o=mysql_fetch_object($r)){ $twitterUser=$o->twitterName; }
if($twitterUser!==NULL){ //and now, query twitter with the username, but only if the user have a twitter username defined. }
And to even make it less db intense, we can cache the twitter username:
PHP Code:
if(!isset($_SESSION['twitterUser'])){ $q="select twitterName from users where userId={$_SESSION['userId']}"; $r=mysql_query($r); while($o=mysql_fetch_object($r)){ $_SESSION['twitterUser']=$o->twitterName; } } else{ if($_SESSION['twitterUser']!==NULL){ //and now, query twitter with the username, but only if the user have a twitter username defined. } }
Not sure it's what you asked, but does it answer your question ?
__________________
Only a biker knows why a dog sticks his head out the window.
Last edited by tripy; 01-21-2010 at 07:21 AM..
|