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

online booking hotel

P: 1
I am creating a website online booking for hotels but I have problems in calculating price between two dates, my problem is:
each hotel that records are created depending on the price schedules types of rooms it contains.
There are three tables that are created

1/ precio_id_year

id_hotel int(11)
id_fecha int(11) auto_increment key
fecha date(Y-m-d)
tarifa_1 float(8.2)
tarifa_2 float(8.2)
tarifa_3 float(8.2)

2/ tipo_hab_id
id_hotel int(11)
id_hab int(11) auto_increment key
tipo_hab varchar(20)
descrepcion text

3/ hotel
id_hotel int(11) auto_increment key
name_hotel varchar(25)
Expand|Select|Wrap|Line Numbers
  1. $get_id = mysql_query("SELECT * FROM hotel", $GLOBALS['DB']) or die (mysql_error());
  2.     while($row = mysql_fetch_array($get_id)){    
  3.     $i = $row['id_hotel'];
  4.     $table = 'anio'.$i.'_2011';
  5.     $get_pro = mysql_query("SHOW COLUMNS FROM ".$table." WHERE FIELD LIKE '%pro_%' ", $GLOBALS['DB']) or die (mysql_error());
  6.     while($row1 = mysql_fetch_array($get_pro)){
  7.         $pro = $row1['Field'];
  8.         //echo $pro;
  9.         //for($i = $star; $i <= $end; $i+=86400){
  10.         $date = date('Y-m-d', $i);
  11.         $fecha = "fecha BETWEEN '".$d."' AND DATE_SUB('".$h."' ,INTERVAL -1 DAY) AND $pro NOT IN(SELECT $pro FROM ".$table." WHERE $pro = 0 ) ";
  12.         //echo 'fecha es '.$date;
  13.         $get_price = mysql_query("SELECT *, SUM($pro) AS $pro  FROM ".$table."  WHERE $fecha  ", $GLOBALS['DB']) or die (mysql_error());
  14.         while($row2 = mysql_fetch_array($get_price)){
  15.             $precio = $row2[$pro];
  16.             //$total = array_sum($precio);
  17.  
  18.             if($row2[$pro]){
  19.                 //if($row2[$pro] == 0 && $pro == $pro){$pro = NULL;}
  20.                 echo '<tr><td>'.$row2['fecha'].'</td><td>'.($precio).'</td><td>'.$pro.'</td><td>'.$table.'</td></tr>';
  21.                 }
  22.  
  23.         }
  24.  
  25.  
  26.     }
  27.     }
  28.  
with this query I get the price but does not ignore the columns which is a zero
Apr 29 '11 #1
Share this question for a faster answer!
Share on Google+

Post your reply

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