Jump to content

trying to do a if function but wont work.


digitus78

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/64434-trying-to-do-a-if-function-but-wont-work/
Share on other sites

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]");
}

}

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");
}

}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.