![]() |
If an SQL WHERE clause equals a certain value, show image.
Okay, so the SQL select query I'm executing is:
Code:
SELECT * FROM stats_new WHERE is_pot = '1' OR is_sr = '1' ORDER BY RAND() LIMIT 1 |
Quote:
Code:
SELECT *, CASE WHEN is_pot = '1' THEN 'image_pot' ELSE 'image_sr' END AS clan_image FROM stats_new WHERE is_pot = '1' OR is_sr = '1' ORDER BY RAND() LIMIT 1 |
Thanks Hambil, would you mind explaining the code for me? I've never used CASE statements.
|
Quote:
SELECT * FROM stats_new WHERE is_pot = '1' OR is_sr = '1' ORDER BY RAND() LIMIT 1 SELECT *, CASE WHEN is_pot = '1' THEN 'image_pot' ELSE 'image_sr' END AS clan_image FROM stats_new WHERE is_pot = '1' OR is_sr = '1' ORDER BY RAND() LIMIT 1 If I fill this in with actual values and turn it into php code it might look like this: PHP Code:
|
Ah-ha! I wasn't sure where the image variable came in -- much appreciated Hambil, thanks again.
|
All times are GMT. The time now is 07:14 AM. |
Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|