Welcome Guest, Not a member yet? Register   Sign In
Random Quote
#7

[eluser]BrianDHall[/eluser]
Oh, I just stumbled into something else you might find useful as far as doing the random quote thing: http://ellislab.com/codeigniter/user-gui...elper.html

Quote:random_element()

Takes an array as input and returns a random element from it. Usage example:

Code:
$quotes = array(
            "I find that the harder I work, the more luck I seem to have. - Thomas Jefferson",
            "Don't stay in bed, unless you can make money in bed. - George Burns",
            "We didn't lose the game; we just ran out of time. - Vince Lombardi",
            "If everything seems under control, you're not going fast enough. - Mario Andretti",
            "Reality is merely an illusion, albeit a very persistent one. - Albert Einstein",
            "Chance favors the prepared mind - Louis Pasteur"
            );

echo random_element($quotes);

With this in ActiveRecord you'd use a call to $query->result_array() after fetching your quotes, then run random_element() on that resulting array.


Messages In This Thread
Random Quote - by El Forum - 09-04-2009, 10:37 AM
Random Quote - by El Forum - 09-04-2009, 10:50 AM
Random Quote - by El Forum - 09-04-2009, 11:06 AM
Random Quote - by El Forum - 09-04-2009, 12:15 PM
Random Quote - by El Forum - 09-04-2009, 01:27 PM
Random Quote - by El Forum - 09-04-2009, 01:51 PM
Random Quote - by El Forum - 09-04-2009, 08:00 PM
Random Quote - by El Forum - 09-05-2009, 04:25 AM



Theme © iAndrew 2016 - Forum software by © MyBB