Help plz...if statement

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mmc
    New Member
    • Nov 2006
    • 9

    Help plz...if statement

    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_arr ay($result)){


    $av = $row11['av'];

    if ($av==0){

    echo"sorry no rooms available";}

    else {

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

    }
    [/php]

    how do sort this problem out?
  • exoskeleton
    New Member
    • Sep 2006
    • 104

    #2
    Originally posted by mmc
    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_arr ay($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...w hat kind of result you really want? :)

    Comment

    • mmc
      New Member
      • Nov 2006
      • 9

      #3
      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.........

      Comment

      • exoskeleton
        New Member
        • Sep 2006
        • 104

        #4
        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

        Comment

        • mklprasanna
          New Member
          • Apr 2007
          • 10

          #5
          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

          Comment

          Working...