The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
||||
|
||||
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 |
#2
|
||||
|
||||
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 |
#3
|
||||
|
||||
Thanks Hambil, would you mind explaining the code for me? I've never used CASE statements.
|
#4
|
||||
|
||||
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:
|
#5
|
||||
|
||||
Ah-ha! I wasn't sure where the image variable came in -- much appreciated Hambil, thanks again.
|
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|