The website is for sale. Check here for more information.
This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.
$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
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
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
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



  • View a Printable Version


Users browsing this thread: 1 Guest(s)

About MyBB-Plugins

Plug Yourself into the best MyBB AddOn.

Copyright © 2009-2021 MyBB-Plugins Forums.

Statistics

  • 51,000+ Posts
  • 19,000+ Members
  • 3,600+ Threads

Impressed? For sure
Check Full Stats here