joecool
09-02-2002, 10:59 AM
Hello, i have a small PHP script, and thought that the way i did it was a long way .. Just wondering if there is a smaller way.
Here is my code.
<?php
$newpm=$DB_site->query_first("SELECT COUNT(*) AS messages FROM privatemessage WHERE userid=$bbuserinfo[userid] AND dateline>$bbuserinfo[lastvisit] AND folderid=0 $ignoreusers");
if ($newpm['messages']==0 and $bbuserinfo['userid']!=0) {
echo("You have 0 messages");
}elseif ($newpm['messages']==1) {
echo("You have 1 message");
}elseif ($newpm['messages']==2) {
echo("You have 2 messages");
}elseif ($newpm['messages']==3) {
echo("You have 3 message");
}elseif ($newpm['messages']==4) {
echo("You have 4 messages");
}elseif ($newpm['messages']==5) {
echo("You have 5 messages");
}elseif ($newpm['messages']==6) {
echo("You have 6 messages");
}elseif ($newpm['messages']==7) {
echo("You have 7 messages");
}elseif ($newpm['messages']==8) {
echo("You have 8 messages");
}elseif ($newpm['messages']==9) {
echo("You have 9 messages");
}elseif ($newpm['messages']>=10) {
echo("You have 10+ messages");
}else
echo("you are not logged in!!!");
?>
Basically its for a small hack, to allow people to see their messages on you homepage, but just wondered if i could make it more simple. ??? Any ideas???
Here is my code.
<?php
$newpm=$DB_site->query_first("SELECT COUNT(*) AS messages FROM privatemessage WHERE userid=$bbuserinfo[userid] AND dateline>$bbuserinfo[lastvisit] AND folderid=0 $ignoreusers");
if ($newpm['messages']==0 and $bbuserinfo['userid']!=0) {
echo("You have 0 messages");
}elseif ($newpm['messages']==1) {
echo("You have 1 message");
}elseif ($newpm['messages']==2) {
echo("You have 2 messages");
}elseif ($newpm['messages']==3) {
echo("You have 3 message");
}elseif ($newpm['messages']==4) {
echo("You have 4 messages");
}elseif ($newpm['messages']==5) {
echo("You have 5 messages");
}elseif ($newpm['messages']==6) {
echo("You have 6 messages");
}elseif ($newpm['messages']==7) {
echo("You have 7 messages");
}elseif ($newpm['messages']==8) {
echo("You have 8 messages");
}elseif ($newpm['messages']==9) {
echo("You have 9 messages");
}elseif ($newpm['messages']>=10) {
echo("You have 10+ messages");
}else
echo("you are not logged in!!!");
?>
Basically its for a small hack, to allow people to see their messages on you homepage, but just wondered if i could make it more simple. ??? Any ideas???