I have a small problem with a code snippet for a random display of images on a page...

first off I have a table that has 10 records, only 3 of them have pictures, I need the pictured records to display randomly...

I can get a random display of ALL the rows, a blank image comes up, but I haven't figured out how to display if the row has something in it...

Here's what I have so far...

SELECT *
FROM cuvideos
WHERE cuvimg = colname
ORDER BY RAND() LIMIT 1

colname varibale

type=integer
Default value=-1
Run-time Value=0

Do I need to make the run-time value a returned row and the type text?

I'm at a loss... Any help would be great!

Ted

I don't now the name of the field containing your image but try something like this:

SELECT *
FROM cuvideos
WHERE cuvimg = colname 
AND cuimgfield is not null
AND cuimgfield <> ''
ORDER BY RAND() LIMIT 1

This will also exempt empty string as well as NULL.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.