you need

$query = SELECT COUNT(*) as count FROM bookings WHERE ('2002-04-04')
BETWEEN booking_start AND booking_end OR ('2002-04-10')BETWEEN
booking_start AND booking_end AND villa_id = ('3')

$villa = mysql_query($query);

while ($result = mysqul_result($villa))
{
echo "We have $result[count] villas booked";
}

and do the same again but change the statement to villa_id = 0

                        Adam

On Mon, 26 Aug 2002, Ray Healy (Data Net Services) wrote:

> Thanks for everyones help yesterday but nI have come up against a problem
> (as I am new). I have created my document as detailed below with notes. I
> can see from the form that I have connected to the server, accessed the
> correct database, created the statment and executed it. The problem is how
> to display the information - as far as I can understand from yesterday if
> the result is 0 then the villa is available. So what I need to do is if the
> result = 0 display villa available and if the result is greater than 0 then
> display villa not available . I know that the variables are getting to the
> query as if I change the echo $result; to $sql;  and key in 3 as the id and
> 2 dates in the form I get the following:
>
> SELECT COUNT(*) FROM bookings WHERE ('2002-04-04') BETWEEN booking_start AND
> booking_end OR ('2002-04-10')BETWEEN booking_start AND booking_end AND
> villa_id = ('3')
>
> So, corrcet me if I am wrong but the query is working its just i cannot see
> anything. I have spent hours on this today, reading books and looking at the
> list. I hope that once I have done one good script I can then start to
> understand it and create more :-)
>
> Thanks for all your help
>
>
> Ray
>
>
> <html>
>  <body>
>  <?php
>
>  if ($submit) {
>
>  // open connection to database
>
>  $db = mysql_connect("localhost", "matrix", "matrix");
>
>  // pick database to use
>
>  mysql_select_db("matrix",$db);
>
>  // create the SQL statement
>
>  $sql = "SELECT COUNT(*) FROM bookings WHERE ('$book_start_date') BETWEEN
> booking_start AND booking_end OR ('$book_end_date')BETWEEN booking_start AND
> booking_end AND villa_id = ('$place')";
>
>  // execute the SQL statement
>
>  $result = mysql_query($sql);
>
>  // display the information
>
>  echo $result;
>
> } else{
>
>  // display form
>
>  ?>
>  <form method="post" action="<?php echo $PHP_SELF?>">
>  Villa id number:<input type="Text" name="place"><br>
>  Start date:<input type="Text" name="book_start_date"><br>
>  End date:<input type="Text" name="book_end_date"><br>
>  <input type="Submit" name="submit" value="Search information">
>  </form>
>  <?php
>  }
>   // end if
>  ?>
>  </body>
>  </html>
>
>
>
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to