Jump to content

Little PHP Problem


selenin

Recommended Posts

Hi

I make 3 querys first Order by DESC, second RAND() and third ASC. Now I want that in the second query can't be the same ids (produgg_users.id) that already taken in the first. And in the third not the ids from first and second. Like I have it now the same users can show up in the RAND() and the ASC like in DESC. Here my Script so far:

 

$rs = mysql_query("select produgg_users.id, twitterUser, credits from produgg_users where twitterUser != '' and  
                produgg_users.id IN (select concat_ws(',', id) from produgg_users where credits > 0 and id != ".$usersClass->userID().") and produgg_users.id NOT IN (select concat_ws(',', followedID) from produgg_activity where followerID = '".$usersClass->userID()."') and produgg_users.id NOT IN (select concat_ws(',', userid) from produgg_featured) ORDER BY credits DESC LIMIT 10") or die(mysql_error()); 


$nr = @mysql_num_rows($rs);



if($nr != 0) {
    
    print "<p>Simply click <strong>get 1 point</strong> and you will automatically FOLLOW the USER and earn the credit!</p>";
print "<p><font color=\"#0066FF\">Top Members</font></p>";
    
    while($row=@mysql_fetch_object($rs))
    {

        $divLeft = '<div id="thediv_'.$row->id.'"><div style="float:left;width:400px;">';
        $divRight = '<div style="float:left;width:150px;">';
        $clearDiv = '<div style="clear:both;"></div>';

        print "$divLeft<img src=\"http://api.twitter.com/1/users/profile_image/".strip_tags($row->twitterUser)."?size=mini\" alt=\"\" />  ".strip_tags($row->twitterUser)."  <font color=\"#999999\" size=\"1\">$row->credits Points</font></div>$divRight <a href='javascript:void(0);' id='vote_$row->id' class='getPoint'>Get 1 Point</a></div>$clearDiv<hr /></div>";
$z = 1;
    }
}

//Lucky Riders

$rs = mysql_query("select produgg_users.id, twitterUser, credits from produgg_users where twitterUser != '' and  
                produgg_users.id IN (select concat_ws(',', id) from produgg_users where credits > 0 and id != ".$usersClass->userID().") and produgg_users.id NOT IN (select concat_ws(',', followedID) from produgg_activity where followerID = '".$usersClass->userID()."') and produgg_users.id NOT IN (select concat_ws(',', userid) from produgg_featured) ORDER BY RAND() LIMIT 5") or die(mysql_error());    
$nr = @mysql_num_rows($rs);

if($nr != 0) {
    
print "<p><font color=\"#0066FF\">Lucky Riders</font></p>";
    
    while($row=@mysql_fetch_object($rs))
    {
        $divLeft = '<div id="thediv_'.$row->id.'"><div style="float:left;width:400px;">';
        $divRight = '<div style="float:left;width:150px;">';
        $clearDiv = '<div style="clear:both;"></div>';

        print "$divLeft<img src=\"http://api.twitter.com/1/users/profile_image/".strip_tags($row->twitterUser)."?size=mini\" alt=\"\" />  ".strip_tags($row->twitterUser)."  <font color=\"#999999\" size=\"1\">$row->credits Points</font></div>$divRight <a href='javascript:void(0);' id='vote_$row->id' class='getPoint'>Get 1 Point</a></div>$clearDiv<hr /></div>";
$z = 1;
    }
}

//Lucky Riders

$rs = mysql_query("select produgg_users.id, twitterUser, credits from produgg_users where twitterUser != '' and  
                produgg_users.id IN (select concat_ws(',', id) from produgg_users where credits > 0 and id != ".$usersClass->userID().") and produgg_users.id NOT IN (select concat_ws(',', followedID) from produgg_activity where followerID = '".$usersClass->userID()."') and produgg_users.id NOT IN (select concat_ws(',', userid) from produgg_featured) ORDER BY credits ASC LIMIT 5") or die(mysql_error());    
$nr = @mysql_num_rows($rs);

if($nr != 0) {
    
print "<p><font color=\"#0066FF\">Last Rides</font></p>";
    
    while($row=@mysql_fetch_object($rs))
    {
        $divLeft = '<div id="thediv_'.$row->id.'"><div style="float:left;width:400px;">';
        $divRight = '<div style="float:left;width:150px;">';
        $clearDiv = '<div style="clear:both;"></div>';

        print "$divLeft<img src=\"http://api.twitter.com/1/users/profile_image/".strip_tags($row->twitterUser)."?size=mini\" alt=\"\" />  ".strip_tags($row->twitterUser)."  <font color=\"#999999\" size=\"1\">$row->credits Points</font></div>$divRight <a href='javascript:void(0);' id='vote_$row->id' class='getPoint'>Get 1 Point</a></div>$clearDiv<hr /></div>";
$z = 1;
    }

}

 

:shrug::confused: :'(

Link to comment
https://forums.phpfreaks.com/topic/227470-little-php-problem/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.