PDA

View Full Version : Having Trouble With If and Else


admin@comptronica.com
03-30-2008, 04:47 PM
Hey guys I'm fairly new at this and what i'm trying to do is fairly simple I think.
K... I have a Apartment Building site and I'm trying show the rental payment by month but if tenant has left I want it to say vacant for that month and every month after for the year. Also I have to query twice because Tenants have rent increases(ann) and rent amount changes.
Sounds simple huh?
Been trying for three days straight and this is what I've got.

<?
$sql="select * from tenants where id='$id'";
$result=mysql_query($sql);
$rows=mysql_fetch_assoc($result);
$d=date ("m");
$term=($rows['term']);
if ('2008/01/01' == ($term))
{
echo "Vacant";
}
else if ($d=="01"){
$sql="SELECT SUM(jan) + SUM(jan1) + SUM(jan2)- SUM(rent) as new_jan FROM tenants where id='$id' and ann between '2008/02/01' AND '2008/12/31'";
$sql="SELECT SUM(jan) + SUM(jan1) + SUM(jan2)- SUM(rent2) as new_jan FROM tenants where id='$id' and ann between '2008/02/01' AND '2008/02/31'";
$result=mysql_query($sql);
$rows=mysql_fetch_assoc($result);
echo ($rows ["new_jan"]);
}
else if ....and I carry on with the dates.
Why doesn't it work?
it will give me answer for tenant that has no term date but tenant that does comes up blank.
Thanks Guys.