Hello There, Guest! › Register

MySubscriptions 2.2 released.
Looking for a custom plugin for your site? Ask here for a quote.

$db->fetch_array only showing one array
#1

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.
Reply
#2

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..
Support PM's will be ignored. Exclamation
Plugins: Announcement Bars - Custom Reputation - Mark PM As Unread
Reply
#3

I did save the file multiple times. But my dreamweaver acts up once now and then.
Reply
#4

Use some advance text editor, something like Notepadd++.
Support PM's will be ignored. Exclamation
Plugins: Announcement Bars - Custom Reputation - Mark PM As Unread
Reply
#5

I rather use Dreamweaver because it is more than just text.
Reply
#6

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).
Support PM's will be ignored. Exclamation
Plugins: Announcement Bars - Custom Reputation - Mark PM As Unread
Reply
#7

What's the problem with Dreamweaver then?
Reply
#8

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.
To download our paid plugins and receive support you must be a paid subscriber. Click here for more information.
Reply
#9

I'm just using it because I find it more useful than Notepad++ for HTML.
Reply




Users browsing this thread: 1 Guest(s)