By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,348 Members | 1,397 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,348 IT Pros & Developers. It's quick & easy.

Help plz...if statement

P: 9
i am trying to view result based on this condition;

User selects start and end date...so

select * from table between start date and end date.

now 2nd check after the above query should be;

if the (quantity = 0) in any of these start and end date...then display message...else if the quantity does not = 0 in any of the row (start & end date) then display the results.

the problem at the moment is the if statement is under the while statement..that is causing to print out both..the msg and the results.....

[php]
while($row11 = mysql_fetch_array($result)){


$av = $row11['av'];

if ($av==0){

echo"sorry no rooms available";}

else {

echo "<form>";......etc }

}
[/php]

how do sort this problem out?
Apr 23 '07 #1
Share this Question
Share on Google+
4 Replies


exoskeleton
100+
P: 104
i am trying to view result based on this condition;

User selects start and end date...so

select * from table between start date and end date.

now 2nd check after the above query should be;

if the (quantity = 0) in any of these start and end date...then display message...else if the quantity does not = 0 in any of the row (start & end date) then display the results.

the problem at the moment is the if statement is under the while statement..that is causing to print out both..the msg and the results.....

[php]
while($row11 = mysql_fetch_array($result)){


$av = $row11['av'];

if ($av==0){

echo"sorry no rooms available";}

else {

echo "<form>";......etc }

}
[/php]

how do sort this problem out?
what results are you trying to view sir, i mean in what format? in your if statement...is will show the result repeatedly of course..now...what kind of result you really want? :)
Apr 24 '07 #2

P: 9
mmc
hi

---------------- Qty type
Day1--------- 0 test1
Day1----------- 3 test2

Day2 2 test1
Day2 1 test2

Day3 1 test1
Day3 1 test2

if Qty is zero...it should not display any of the test1.....for any days...it should only display test2...

Day1 3 test2
Day2 2 test2
Day3 1 test2

and from here ....then i wanted to display the lowest qty row...so FINAL output

Day3 1 test2.........
Apr 24 '07 #3

exoskeleton
100+
P: 104
hi sir...what are the inputs when searching? should i enter DAY1 or TEST2? if test2 then the result must be:

COL1 || QTY || ITEM

DAY1 || 2 || TEST2
DAY2 || 1 || TEST2
DAY3 || 4 || TEST2

if QTY == 0 then ... it should not display, right? for example:

DAY4 || 0 || TEST2
Apr 25 '07 #4

P: 10
Hi,
In the result set you may have some Quantitiy might be zero.So that two msgs will be displayed.If your desire out put is ,

whenever any one of the quantitity is zero then don;t display the form at all.
If this is the case then you can set the flag variable and assign the form to one variable.if the flag is set then display the msg otherwise display the form.

I think by this you can sort this problem.

Prasanna
Apr 25 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.