digitus78 Posted August 11, 2007 Share Posted August 11, 2007 ok im trying to get this IF command to work right so if a user doesnt have a avatar it goes to the default one but if the do it will display it. $avatarinfo = mysql_query("SELECT user.avatarid, user.avatarrevision, avatarpath, NOT ISNULL(customavatar.userid) AS hascustom, customavatar.dateline,customavatar.width, customavatar.height FROM vb_user AS user LEFT JOIN vb_avatar AS avatar ON avatar.avatarid = user.avatarid LEFT JOIN vb_customavatar AS customavatar ON customavatar.userid = user.userid WHERE user.userid = '$userid'"); while ($query_row=mysql_fetch_array($avatarinfo)) { if (!$avatarinfo) { $avatarurl= imagecreatefromgif('forums/images/avatars/noavatar.gif'); } else { $avatarurl= imagecreatefromgif("forums/$query_row[avatarpath]"); } } any help is appreciated Quote Link to comment https://forums.phpfreaks.com/topic/64434-trying-to-do-a-if-function-but-wont-work/ Share on other sites More sharing options...
LiamProductions Posted August 11, 2007 Share Posted August 11, 2007 Not sure... but you could give it a try: $avatarinfo = mysql_query("SELECT user.avatarid, user.avatarrevision, avatarpath, NOT ISNULL(customavatar.userid) AS hascustom, customavatar.dateline,customavatar.width, customavatar.height FROM vb_user AS user LEFT JOIN vb_avatar AS avatar ON avatar.avatarid = user.avatarid LEFT JOIN vb_customavatar AS customavatar ON customavatar.userid = user.userid WHERE user.userid = '$userid'"); while ($query_row=mysql_fetch_array($avatarinfo)) { if (!$avatarinfo == "") { $avatarurl= imagecreatefromgif('forums/images/avatars/noavatar.gif'); } else { $avatarurl= imagecreatefromgif("forums/$query_row[avatarpath]"); } } Quote Link to comment https://forums.phpfreaks.com/topic/64434-trying-to-do-a-if-function-but-wont-work/#findComment-321254 Share on other sites More sharing options...
digitus78 Posted August 11, 2007 Author Share Posted August 11, 2007 using that version makes it to where all users show a noavatar.gif hmmmm im confused over this one and its probably so simple. Quote Link to comment https://forums.phpfreaks.com/topic/64434-trying-to-do-a-if-function-but-wont-work/#findComment-321258 Share on other sites More sharing options...
LiamProductions Posted August 11, 2007 Share Posted August 11, 2007 I thought that what you wanted if they didnt have an avartar ^o) Quote Link to comment https://forums.phpfreaks.com/topic/64434-trying-to-do-a-if-function-but-wont-work/#findComment-321260 Share on other sites More sharing options...
digitus78 Posted August 11, 2007 Author Share Posted August 11, 2007 what i was wanting is the code above calls to the DB and gets the avatar path then the code below displays the avatar but if the the avatar path field is empty i want it to desplay the noavatar.gif hope that makes sense lol Quote Link to comment https://forums.phpfreaks.com/topic/64434-trying-to-do-a-if-function-but-wont-work/#findComment-321268 Share on other sites More sharing options...
digitus78 Posted August 11, 2007 Author Share Posted August 11, 2007 fixed just took a bit of tinkering thanks for your help $avatarinfo = mysql_query("SELECT user.avatarid, user.avatarrevision, avatarpath, NOT ISNULL(customavatar.userid) AS hascustom, customavatar.dateline,customavatar.width, customavatar.height FROM vb_user AS user LEFT JOIN vb_avatar AS avatar ON avatar.avatarid = user.avatarid LEFT JOIN vb_customavatar AS customavatar ON customavatar.userid = user.userid WHERE user.userid = '$userid'"); while ($query_row=mysql_fetch_array($avatarinfo)) { $avatarpat = "$query_row[avatarpath]"; if ($avatarpat == "") { $avatarurl= imagecreatefromgif('forums/images/avatars/noavatar.gif'); } else { $avatarurl= imagecreatefromgif("forums/$avatarpat"); } } Quote Link to comment https://forums.phpfreaks.com/topic/64434-trying-to-do-a-if-function-but-wont-work/#findComment-321271 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.