onewake Posted September 29, 2008 Share Posted September 29, 2008 I've got the following code that I'm trying to make into an IF/ELSE argument...can anybody help me out with it? I've tried several things and can't seem to make it work. <li class="<?php if (1 == $comment->user_id) $oddcomment = "authcomment"; echo $oddcomment; ?>" id="comment-<?php comment_ID() ?>"> <li class="<?php if (1 != $comment->user_id) $oddcomment = "othrcomment"; echo $oddcomment; ?>" id="comment-<?php comment_ID() ?>"> I'm basically trying to make it say, "IF the userID=1, $oddcomment = "authcomment" ELSE $oddcomment = "othrcomment" Quote Link to comment https://forums.phpfreaks.com/topic/126315-solved-could-someone-help-me-with-this-simple-ifelse-argument/ Share on other sites More sharing options...
ram4nd Posted September 29, 2008 Share Posted September 29, 2008 I don't get this part: $comment->user_id <li class="<?php if ($comment->user_id == 1) $oddcomment = "authcomment"; else $oddcomment = "othrcomment"; echo $oddcomment; ?>" id="comment-<?php comment_ID() ?>"> Quote Link to comment https://forums.phpfreaks.com/topic/126315-solved-could-someone-help-me-with-this-simple-ifelse-argument/#findComment-653175 Share on other sites More sharing options...
onewake Posted September 29, 2008 Author Share Posted September 29, 2008 It's for a wordpress blog and I think it's just stating that if the userID=1 (the admin) then to give the subsequent output. Is that what you meant? Quote Link to comment https://forums.phpfreaks.com/topic/126315-solved-could-someone-help-me-with-this-simple-ifelse-argument/#findComment-653177 Share on other sites More sharing options...
Barand Posted September 29, 2008 Share Posted September 29, 2008 <li class="<?php echo (1 == $comment->user_id) ? 'authcomment' : 'othrcomment' ?>" id="comment-<?php echo comment_ID() ?>"> Quote Link to comment https://forums.phpfreaks.com/topic/126315-solved-could-someone-help-me-with-this-simple-ifelse-argument/#findComment-653178 Share on other sites More sharing options...
Dragen Posted September 29, 2008 Share Posted September 29, 2008 <li class="<?php ((1 == $comment->user_id) ? echo 'authcomment' : 'othrcomment'); ?>" id="comment-<?php comment_ID() ?>"> <li class="<?php ((1 != $comment->user_id) ? echo 'authcomment' : 'othrcomment'); ?>" id="comment-<?php comment_ID() ?>"> EDIT: Barand got their first.. Quote Link to comment https://forums.phpfreaks.com/topic/126315-solved-could-someone-help-me-with-this-simple-ifelse-argument/#findComment-653179 Share on other sites More sharing options...
onewake Posted September 29, 2008 Author Share Posted September 29, 2008 Barand...I can't thank you enough! It worked perfectly. And thanks for offering to help Dragen. Quote Link to comment https://forums.phpfreaks.com/topic/126315-solved-could-someone-help-me-with-this-simple-ifelse-argument/#findComment-653187 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.