Reply
How to get more results from MYSQL
Old 04-21-2008, 08:32 AM How to get more results from MYSQL
SPS
Junior Talker

Posts: 3
I have an E107 forum that I want to show the 3 or 5 most recent sign ups.

There is a plugin that shows the latest sign up.

I need to know how to change the code or the MySQL to get more?

This is the complete code the plug in uses any suggestions would be great.

I have tried raising the limit but that didn't work:
LIMIT 0,3
LIMIT 3

PHP Code:
<?php
if (!defined('e107_INIT')) { exit; }
if(!
defined('e_TRACKING_DISABLED') && varset($pref['track_online']))
{
        global 
$e107cache;
        
$members_totals $e107cache->retrieve('online_menu_totals'120);
        if(
$members_totals == false)
    {
                
$total_members $sql->db_Count('user');
                
$newest_member $sql->db_Select('user''user_id, user_name'"user_ban='0' ORDER BY user_join DESC LIMIT 0,1");
                
$row $sql->db_Fetch();
                
extract($row);
                
$members_totals  ONLINE_L5.': '.$total_members.'<br /><br /><br />';
          
$members_totals .= ONLINE_L6.': <a href="'.e_HTTP.'user.php?id."'.$user_id.'">'.$user_name.'</a>';
                
$e107cache->set('online_menu_totals'$members_totals);
        }
        
$text $members_totals;
}
else
{
        if(
ADMIN)
    {
                global 
$tp;  
                
$text $tp->toHtml(TRACKING_MESSAGE,TRUE);
        }
    else
    {
                return 
'';
        }
}
$ns->tablerender(ONLINE_L4$text'online');

?>
SPS is offline
Reply With Quote
View Public Profile
 
Sponsored Links (We share ad revenue):
 
Old 04-23-2008, 12:08 AM Re: How to get more results from MYSQL
SPS
Junior Talker

Posts: 3
Bump.
SPS is offline
Reply With Quote
View Public Profile
 
Old 04-23-2008, 07:51 AM Re: How to get more results from MYSQL
King Spam Talker

Posts: 1,029
Maybe Tripy on one of the sharp php guys will respond. I can tell you what you need to do, but writing working code is beyond me.

That script is pulling the last member only as you know. It would need to SELECT from MEMBERS, ODER by date and have a LIMIT X. Where X is the number you want to display.
colbyt is offline
Reply With Quote
View Public Profile
 
Old 04-23-2008, 09:38 AM Re: How to get more results from MYSQL
Ultra Talker

Posts: 308
Even if you change the limit clause to retrieve more rows, the code for fetching and displaying the result set will only operate on first record of the resultset.

PHP Code:
<?php
if (!defined('e107_INIT')) { exit; }
if(!
defined('e_TRACKING_DISABLED') && varset($pref['track_online']))
{
        global 
$e107cache;
        
$members_totals $e107cache->retrieve('online_menu_totals'120);
        if(
$members_totals == false)
    {
                
$total_members $sql->db_Count('user');
                
$members_totals  ONLINE_L5.': '.$total_members.'<br /><br /><br />'
                
$num_new_users 5;
                
$newest_member $sql->db_Select('user''user_id, user_name'"user_ban='0' ORDER BY user_join DESC LIMIT 0,$num_new_users");
                
/* have no idea what method is used by this particular sql class to get number of rows in the resultset, replace it with appropriate method */
                
for($i 0;$i $sql->num_rows();$i++)
                {  
                  
$row $sql->db_Fetch();
                  
extract($row);
                  
$members_totals .= ONLINE_L6.': <a href="'.e_HTTP.'user.php?id."'.$user_id.'">'.$user_name.'</a><br />';
                }

                
$e107cache->set('online_menu_totals'$members_totals);
        }
        
$text $members_totals;
}
else
{
        if(
ADMIN)
    {
                global 
$tp;  
                
$text $tp->toHtml(TRACKING_MESSAGE,TRUE);
        }
    else
    {
                return 
'';
        }
}
$ns->tablerender(ONLINE_L4$text'online');

?>
replace $sql->num_rows with appropriate function in for loop. I have no way to test this and don't know whether this will work correctly or not, but i think it is good enough show you the basic concept.
__________________
tiny url
dman_2007 is offline
Reply With Quote
View Public Profile Visit dman_2007's homepage!
 
Old 04-27-2008, 02:31 PM Re: How to get more results from MYSQL
tripy's Avatar
Fetchez la vache!

Latest Blog Post:
Pretty pretty please….
Posts: 1,689
Name: Thierry
Location: In the void
Sorry, but I don't know how this should be done.

The strange thing I notice, is that this seems to works against a caching mechanism ($e107cache->retrieve), so maybe it's the reason the modification you made at first didn't worked. There was already a result in the site cache mechanism, and it used that value.

I sadly cannot say anything more, I don't know this product, nor the way it works.Sorry.
__________________
Listen to the ducky: "This is awesome!!!"

tripy is offline
Reply With Quote
View Public Profile
 
Old 04-27-2008, 02:47 PM Re: How to get more results from MYSQL
SPS
Junior Talker

Posts: 3
Hello tripy yes there is a cache system but I have it turned off

dman_2007 could you explain more on this
Quote:
replace $sql->num_rows
SPS is offline
Reply With Quote
View Public Profile
 
Old 04-27-2008, 11:13 PM Re: How to get more results from MYSQL
Ultra Talker

Posts: 308
Quote:
Originally Posted by SPS View Post
Hello tripy yes there is a cache system but I have it turned off

dman_2007 could you explain more on this
I mean replace it with the actual method to retrieve number of rows returned by the previous select query executed.
__________________
tiny url
dman_2007 is offline
Reply With Quote
View Public Profile Visit dman_2007's homepage!
 
Sponsored Links (We share ad revenue):
 
Reply     « Reply to How to get more results from MYSQL
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML


Page generated in 0.18253 seconds with 14 queries