MyBB-Plugins Forums

Full Version: $db->fetch_array only showing one array
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hey,

Currently I'm trying to use the following code to put out ALL entries in a certain database (within the "WHERE"). The problem is that it only puts out one value, one array, while I want it to return multiple arrays, with an array in it containing data as "uid", "name", etc.

I'm using the following code:
PHP Code:
function list_entries($raffle_start$raffle_end) {
        global 
$db;
        
        
$sql 
            
"
            SELECT
                *
            FROM
                <prefix removed>_raffle_entries
            WHERE
                time > "
.$raffle_start."
            AND
                time < "
.$raffle_end."
            LIMIT 5"
            
;
            
        
$query $db->query($sql);
        
$entries = array();
        while(
$records $db->fetch_array($query)) {
            
$entries[] = $records;
        }

        return 
$entries;
    } 

It doesn't seem to work, atleast, it only returns one array:
Code:
Array (
[uid] => 1
[name] => Ruben
[time] => 1354366024
)
It should return:
Code:
Array (
[1] => Array (
[uid] => 1
[name] => Ruben
[time] => 1354366024  
)
[2] => Array (
[uid] => 2
[name] => Jordan
[time] => 1354366510
)
)
I'm sure these values exist in the database.

EDIT:
Fixed it, forgot to put $records = array(), but after I put that, refreshed the page, and then removed that line again, to show my dad what was wrong (I talk with him a lot about PHP), it still worked. Strange.
I see no reason for it to fail, may be you didn't save the file? Tongue Happens sometimes to me, editing a different file or not saving them..
I did save the file multiple times. But my dreamweaver acts up once now and then.
Use some advance text editor, something like Notepadd++.
I rather use Dreamweaver because it is more than just text.
Well, if you are writing MyBB friendly code then you shouldn't be using Dreamweaver, it doesn't work like that (again, if you are writing friendly code, i.e: You plan to release a plugin that is well written).
What's the problem with Dreamweaver then?
Most people use DW because it generates HTML code. If you are writing plugins there is no point in using it, you need to stick to the templates.
I'm just using it because I find it more useful than Notepad++ for HTML.