Kenny must be tweaking your code.
I am now trying to learn some basic SQL super-quick, and then plug it into some PHP. I really should learn to not offer to help people, especially when you don't have a clue what you're doing :S
Probably not worth the effort, as it's only a handful of queries/pages that need fixing.
It's basically selecting 6 random rows from the database and then printing them out one at a time at various points on a webpage.
I think I've almost got it sorted, not knowing what you're doing really makes it quite interesting though :D
Anyone want to help me with this? And by help, i mean tell me exactly what to type :$
I have a table with around 100 entries, each one is a vetted customer testimonial type thing and the data isn't likely to change/grow much.
What I need is:
Select 6 of them at random, then they'll be displayed at various points on a page.
I've got an SQL query working for it (I know it's not the most efficient/fastest way of doing it, but it seemed the most straightforward way to get 6 unique random rows):
SELECT text FROM `content` ORDER BY RAND() LIMIT 0,6
Now how do i get that into an array so I can print each row result individually? All the stuff online seems to be about finding individual rows and adding them to an array, not finding 6 rows and adding each row to an array.
Or should I bite the bullet and learn some PHP so I can do it myself? Just sees like a waste as I'm unlikely to ever need it again after this :$
$query = mysql_query("SELECT text FROM `content` ORDER BY RAND() LIMIT 0,6"); $hooray = array(); while($result = mysql_fetch_array($query)) { $hooray[] = $result; } print_r($hooray);
Ah-hah. The problem is with how I'm trying to print the array elements.
If I use "print" it just outputs "Array". print_r prints the content, but does it like this:
Array ( [0] => The service was excellent. [text] => The service was excellent. )
How on earth do i just get the bit of text I need out of it?! This shit was so easy in QBASIC :(