Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

The Database Forum


You are currently viewing our The Database Forum as a guest. Please register to participate.
Login



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

Posts: 6
Trades: 0
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
 
 
Register now for full access!
Old 04-23-2008, 01:08 AM Re: How to get more results from MYSQL
SPS
Novice Talker

Posts: 6
Trades: 0
Bump.
SPS is offline
Reply With Quote
View Public Profile
 
Old 04-23-2008, 08:51 AM Re: How to get more results from MYSQL
Defies a Status

Posts: 1,605
Trades: 0
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

Please login or register to view this content. Registration is FREE
colbyt is offline
Reply With Quote
View Public Profile
 
Old 04-23-2008, 10:38 AM Re: How to get more results from MYSQL
Ultra Talker

Posts: 310
Trades: 0
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.
dman_2007 is offline
Reply With Quote
View Public Profile
 
Old 04-27-2008, 03:31 PM Re: How to get more results from MYSQL
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
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.
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 04-27-2008, 03:47 PM Re: How to get more results from MYSQL
SPS
Novice Talker

Posts: 6
Trades: 0
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-28-2008, 12:13 AM Re: How to get more results from MYSQL
Ultra Talker

Posts: 310
Trades: 0
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.
dman_2007 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to How to get more results from MYSQL
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB 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.25006 seconds with 12 queries