| | |
Need help with If and While Clauses
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Mar 2007
Posts: 13
Reputation:
Solved Threads: 0
Here is my code:
What I want it to do is if there is a birthday show it, but if there is not a birthday say "It is everyone's unbirthday!" Should be easy but it isn't working. The while statement by itself is working, in other words I can get it to show me a list of today's birthdays, but if it is a no birthday month it isn't working. Thanks in advance for the help.
if ($num = $i) {
echo ("<p align='left'>It's everyone's unbirthday today!</p><br>")
}
else {
while ($i < $num) {
$name=mysql_result($result,$i,"username");
$day=mysql_result($result,$i,"bday");
$city=mysql_result($result,$i,"lpcity");
$email=mysql_result($result,$i,"emailques");
echo "<br>Username: $name<br>Birthday: $day<br>City From: $city<br>On Emailing?: $email<br><br><hr><br>";
$i++;
}
echo("<p align='center'><font face='Arial' size='3' color='#FF0000'>If your information is wrong please email lpbirthdays@johnpedroza.com and we will change it.</font></p>");
echo("<p></p>");
include("adder.html");
echo("<p></p>");
include("footer.html");
?>What I want it to do is if there is a birthday show it, but if there is not a birthday say "It is everyone's unbirthday!" Should be easy but it isn't working. The while statement by itself is working, in other words I can get it to show me a list of today's birthdays, but if it is a no birthday month it isn't working. Thanks in advance for the help.
I've not looked at your code extensively but if statements need a double equals sign to do comparisons.
i.e.
Assuming a table as such...
pedantic_table (table name)
What I would do is pipe all your data from your table into an array then compare each birthday date as you go along. If the birthday matches the curDate() show "it's your birthday" if not show "happy unbirthday"
i.e.
if (something == condition)Assuming a table as such...
pedantic_table (table name)
PHP Syntax (Toggle Plain Text)
+----+-------+------------+ | id | name | birthday | +----+-------+------------+ | 1 | Dan | 1995-09-01 | | 2 | Dani | 1982-11-11 | | 3 | Sally | 1989-10-13 | +----+-------+------------+
Last edited by iamthwee; Jun 24th, 2007 at 7:40 am.
*Voted best profile in the world*
![]() |
Similar Threads
- sql query problem with MS Access and C# (C#)
- Dr Scheme Tutorial (Computer Science)
- Search facility for a drop down box (MySQL)
- Multiple results (MySQL)
- Check existing users in the database (ASP)
- Fried PC, Reversed Polarity, Hot Chassis...Not Happy!!! (Cases, Fans and Power Supplies)
- Exit Codes (Python)
- Filtering data from access database (Visual Basic 4 / 5 / 6)
- Help with ADMIN side of login ASP.NET (ASP.NET)
Other Threads in the PHP Forum
- Previous Thread: PHP Resource
- Next Thread: can I get a title from an html header tag?
| Thread Tools | Search this Thread |
# 5.2.10 ajax apache api array beginner binary broken cakephp checkbox class clean clients cms code cron curl database date display dissertation dynamic echo echo$_get[x]changingitintovariable... email error file files folder form forms function functions google href htaccess html image images include insert integration ip java javascript joomla ldap legislation limit link local login loop mail memberships menu mlm multiple multipletables mysql mysqlquery oop open paypal pdf persist php problem query radio random recursion regex remote rss script search server sessions sms soap sockets source space spam sql syntax system table tutorial update upload url validator variable video web xml youtube






