blocblue!!!thank you so much!!!!its perfect!your the best man..you save my ass out here..i'm in debt with you gain thank you so much....

im still not getting it the right output

here is the thing

if i put in date1 2012-06-01 and on date2=2012-06-01 it needed to have a default total and that total must be 2500..but if i change date2 to 2012-06-02 thats the time that it will need to add another 2500 to get the total of 5000

e.g

date1=2012-06-01
date2=2012-06-01

total=2500

e.g
date1=2012-06-01
date1=2012-06-02

total=5000

and so on until it get to

date1=2012-06-01
date1=2012-06-07

total=15000

again sorry if im pulling you to my problem..but help is really needed out here..thanks

hi i got it already but the problem is im getting wrong output

here's the code

    <?php

    $timezone = "Asia/Shanghai";
    if(function_exists('date_default_timezone_set')) date_default_timezone_set($timezone);
    echo date('d-m-Y H:i');

    /*These look like they are sent via form submit to this program*/
    $date1 = '2012-06-01'; // pick up date
    $date2 = '2012-06-01'; // return date

    $perday=2500;
    $permonth=52500;
    $perweek=15000;

    $datetime1 = new DateTime($date1);
    $datetime2 = new DateTime($date2);
    $interval = $datetime1->diff($datetime2); // the math for the difference
    $rest =  $interval->format('%d days');  // this may contain weeks
    $week = intval($rest / 7);              // weeks extracted from the above var.                
    $mon = $interval->format('%m');  // The mon from formatting
    $day = intval($rest % 7);      // This line MUST STAY to figure number of days

    echo 'week '.$week . '<br />';  // The echos are for your benifit and should be commented out or erased
    echo 'day '.$day . '<br />';
    echo ' months '.$mon .'<br />';

    $total = $mon * $permonth + $week * $perweek + $day * $perday;
    echo $total . '<br />';
    ?> 

in the date part of this code i try to put the pick up date to 2012-06-01 the same with the return date..but im having a wrong output

it must be " 2500 "

but instead im getting this 0 for the total

22-06-2012 20:21
week 0
day 0
months 0
0

and also when i change the pick up date to 2012-06-01 and the return date to 2012-06-02

instead of getting "5000"

im getting

22-06-2012 20:28

week 0
day 2
months 0
2500

sorry ...

ok but when i put new DateTime(); im having this error

Fatal error: Uncaught exception 'Exception' with message 'DateTime::__construct() [<a href='datetime.--construct'>datetime.--construct</a>]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'UTC' for '8.0/no DST' instead' in C:\xampp\htdocs\msicfinal\samp.php:10 Stack trace: #0 C:\xampp\htdocs\msicfinal\samp.php(10): DateTime->__construct('2012-04-01') #1 {main} thrown in C:\xampp\htdocs\msicfinal\samp.php on line 10

any idea?

hi im having an error with my code can anyone help me try to fix my problem

the error is

Fatal error: Call to a member function diff() on a non-object in C:\xampp\htdocs\msicfinal\samp.php on line 12

and my code is

<?php
/*These look like they are sent via form submit to this program*/
$date1 = '2012-04-01'; // pick up date
$date2 = '2012-05-27'; // return date

$perday=2500;
$permonth=52500;
$perweek=15000;

$datetime1 = ($date1);
$datetime2 = ($date2);
$interval = $datetime1->diff($datetime2); // the math for the difference
$rest =  $interval->format('%d days');  // this may contain weeks
$week = intval($rest / 7);              // weeks extracted from the above var.                
$mon = $interval->format('%m');  // The mon from formatting
$day = intval($rest % 7);      // This line MUST STAY to figure number of days

$total = $mon * $permonth + $week * $perweek + $day * $perday;
echo $total . '<br />';
?> 

the purpose of this code is to compute the rate depending on the date

and if you need to see the actual web here is the link http://europcar1.com.ph/selfdrive.php

just choose NO in the part that will ask you if you have a corporate accnt..thanks

228

this are the screenshot output

146

hi need a hand here..

im having trouble in making my code work(well actually im not getting it)what i need to do is to compute the rate of vehicle that is rented..the only thing that i came up is with the perday rate and the other 2 i cant find a way(i really sucks with formula )here is the thing..

SELF - DRIVE RATES

  1. Minimum rental periods :
    Daily - 24 hours
    Weekly - 7 days
    Monthly - 30 days

CAR
Toyota VIOS 1.3 MT
DAILY
2,500

WEEKLY
15,000

MONTHLY
52,500

and this is the code that i can came up

<?php
$rday=$_POST['txtrday'];
$pday=$_POST['txtpday'];
  $vehicle;

    $phr;
    $total;
    $totalhr;
    $pday;
    $totald;
    $totalday;
    $rmonth;
    $pmonth;
    $totalm;
    $totalmonth;

if($vehicle=="Toyota VIOS 1.3 MT")
{
    $perday=2500;
    $permonth=52500;
    $perweek=15000;

    if($rday>$pday)
        {
        $totald=($rday)-($pday);

        }
    else if($rday==$pday)
        {
        $totalday=$perday;
        }

    if($rmonth>$pmonth)
        {
        $totalm=$rmonth-$pmonth;

        }
    else if($rmonth==$pmonth)
        {
        $totalmonth;
        }

        $totalday=$perday * $totald+2500;
        $totalmonth=$totalm * $permonth;
        $rate=$totalday + $totalmonth;     
}
?>

this will be the weekly rate output

e.g
form1
vehicle=Toyota VIOS 1.3 MT
pday=3
rday=10
when click submit it will be directed in

form2

rate=15000

because it is already equivalent to 7 days

in need of lot of help right now ..this will be the last part of my project so please

embarrassing..it took me 1 whole day to figure out whats the problem with the code and with no avail in finding any..just a moment ago i figured out that i put the same price in twice..thats explain why im getting wrong output..:(

yeah i miss that one..gonna check if its work...as for the $zone yeah it is base on the input of the user. well basically the user will choose from a dropdown menu to get the zone..

but when it comes to Paranaque 1 its not working properly.. i already try to scan and find a bug in my code but i cant find any..

@ cerial: well in the lower or upper case issue its not really a problem because i use jquery to make all the input text all uppercase..the weard thing is the other condtion is working fine..

here is an example code that show the correct rate

if(($origin=="NAIA 1" && $vehicle=="Vios" && $zone=="Quezon 7") && ($destination=="REGALADO HIWAY" || $destination=="PASONG PUTTING" || $destination=="KALIGAYAHAN" || $destination=="COMMONWEALTH"))
{
$rate=2200;
}   
if(($origin=="NAIA 1" && $vehicle=="Innova" && $zone=="Quezon 7") && ($destination=="REGALADO HIWAY" || $destination=="PASONG PUTTING" || $destination=="KALIGAYAHAN" || $destination=="COMMONWEALTH"))
{
$rate=3280;
}
if(($origin=="NAIA 1" && $vehicle=="Van" && $zone=="Quezon 7") && ($destination=="REGALADO HIWAY" || $destination=="PASONG PUTTING" || $destination=="KALIGAYAHAN" || $destination=="COMMONWEALTH"))
{
$rate=4900;
}

here is the complete code but it is really a mess so please bare with me

<?php  
// NAIA TRANSFER-------------------------------------------------------
if($origin=="NAIA 1" && $vehicle=="Vios" && $zone=="Inter NAIA" && $destination=="NAIA 2")
{
$rate=300;
}   
 if($origin=="NAIA 1" && $vehicle=="Innova" && $zone=="Inter NAIA" && $destination=="NAIA 2")
{
$rate=590;
}
if($origin=="NAIA 1" && $vehicle=="Van"  && $zone=="Inter NAIA" && $destination=="NAIA 2")
{
$rate=880;
}   
if($origin=="NAIA 1" && $vehicle=="Vios" && $zone=="Inter NAIA"  && $destination=="NAIA 3")
{
$rate=450;
}       
if($origin=="NAIA 1" && $vehicle=="Innova" && $zone=="Inter NAIA" && $destination=="NAIA 3")
{
$rate=775;
}   
if($origin=="NAIA 1" && $vehicle=="Van" && $zone=="Inter NAIA" && $destination=="NAIA 3")
{
$rate=1100;
}   
if($origin=="NAIA 1" && $vehicle=="Vios" && $zone=="Inter NAIA" && $destination=="OLD DOMESTIC")
{
$rate=380;
}   
if($origin=="NAIA 1" && $vehicle=="Innova" && $zone=="Inter NAIA" && $destination=="OLD DOMESTIC")
{
$rate=630;
}   
if($origin=="NAIA 1" && $vehicle=="Van" && $zone=="Inter NAIA" && $destination=="OLD DOMESTIC")
{
$rate=880;
}
//--------------------------PASAY 1-------------------- 
if(($origin=="NAIA 1" && $vehicle=="Vios" && $zone=="Pasay 1") && ($destination=="VILLAMOR AIRBASE" || $destination=="RIVERA" || $destination=="AIRMEN'S VILLAGE" || $destination=="PILDERA 1" || $destination=="PILDERA 2"))
{
$rate=500;
}
if(($origin=="NAIA 1" && $vehicle=="Innova" && $zone=="Pasay 1") && ($destination=="VILLAMOR AIRBASE" || $destination=="RIVERA" || $destination=="AIRMEN'S VILLAGE" || $destination=="PILDERA 1" || $destination=="PILDERA 2"))
{
$rate=750;
}
if(($origin=="NAIA 1" && $vehicle=="Van" && $zone=="Pasay 1") && ($destination=="VILLAMOR AIRBASE" || $destination=="RIVERA" || $destination=="AIRMEN'S VILLAGE" || $destination=="PILDERA 1" || $destination=="PILDERA 2"))
{
$rate=1125;
}
//--------------------------PASAY 2---------------------
if(($origin=="NAIA 1" && $vehicle=="Vios" && $zone=="Pasay 2") && ($destination=="GSIS" || $destination=="SENATE" || $destination=="WTC" || $destination=="FB HARRISON" || $destination=="BSP" || $destination=="CENTURY PARK" || $destination=="RUSSIAN EMBASSY" || $destination=="VIETNAM EMBASSY" || $destination=="RIZAL MEMORIAL"))
{
$rate=550;
}   
if(($origin=="NAIA 1" && $vehicle=="Innova" ...

well basically the user will fill up a form. in that form theire is a texbox such as txtzone,txtvehicle,txtorigin and txtdestination..when submitted it must show the rate of the vehicle

e.g
if origin is equal to "NAIA 1" AND zone is equal to "Paranaque 1" AND vehicle is equal to "VIOS "AND destination is equal to "UNIWIDE" OR "COSTAL MALL" OR "DFP " THEN rate is 550

OUTPUT

zone= Paranaque 1
vehicle=VIOS
origin=NAIA 1
destination=DFP

RATE : PHP 550.00

but im having an error it display a wrong rate..

hi anybody can help me analyze this code..im not getting the correct output..

if(($origin=="NAIA 1" && $vehicle=="Small Car" && $zone=="Paranaque 2") && ($destination=="BACLARAN" || $destination=="SAN DIONISIO" || $destination=="BICUTAN INTERCHANGE" || $destination=="MULTINATIONAL VILLAGE" || $destination=="MOONWALK" || $destination=="SM SUCAT" || $destination=="DON BOSCO" || $destination=="SUN VALLEY" || $destination=="BETTER LIVING" || $destination=="MERVILLE" || $destination=="MARCELO GREEN" || $destination=="KALAYAAN" || $destination=="UNITED PARANAQUE"))
{
$rate=550;
}
if(($origin=="NAIA 1" && $vehicle=="Innova" &&  $zone=="Paranaque 2") && ($destination=="BACLARAN" || $destination=="SAN DIONISIO" || $destination=="BICUTAN INTERCHANGE" || $destination=="MULTINATIONAL VILLAGE" || $destination=="MOONWALK" || $destination=="SM SUCAT" || $destination=="DON BOSCO" || $destination=="SUN VALLEY" || $destination=="BETTER LIVING" || $destination=="MERVILLE" || $destination=="MARCELO GREEN" || $destination=="KALAYAAN" || $destination=="UNITED PARANAQUE"))

{
$rate=865;
}
if(($origin=="NAIA 1") && ($vehicle=="Van") && ($zone=="Paranaque 2") && ($destination=="BACLARAN" || $destination=="SAN DIONISIO" || $destination=="BICUTAN INTERCHANGE" || $destination=="MULTINATIONAL VILLAGE" || $destination=="MOONWALK" || $destination=="SM SUCAT" || $destination=="DON BOSCO" || $destination=="SUN VALLEY" || $destination=="BETTER LIVING" || $destination=="MERVILLE" || $destination=="MARCELO GREEN" || $destination=="KALAYAAN" || $destination=="UNITED PARANAQUE"))

{
$rate=1300;
}

ok i got it
instead of this
if($origin=="NAIA 1" && $vehicle=="Vans" && $destination=="Manila" || $destination=="Cam Sur" || $destination=="Boracay" )

i put
if(($origin=="NAIA 1" && $vehicle=="Van") &&( $destination=="Manila" || $destination=="Cam Sur" || $destination=="Boracay" ))

and its working now..

pritaeas commented: Thanks for sharing +13

guys i'm having a really big problem right now..im trying to make a conditional statement using php but im having an logical error or syntax error..im trying to compute for the car rate but im not getting a correct output

e.g

i have a list of car which are "Small Car" "Innova" "Van" and there prices will depend on the location if the location is let say "Manila" or "Cam Sur" or "Boracay" then
Small Car price is 550.00
Innova price is 700.00
Van price is 1000.00

here is the code

<?php
 $vehicle;
      $rhr;
    $phr;
    $total;
    $totalhr;
    $rday;
    $pday;
    $totald;
    $totalday;
    $rmonth;
    $pmonth;
    $totalm;
    $totalmonth;

if($origin=="NAIA 1" && $vehicle=="Small Car" && $destination=="Manila" || $destination=="Cam Sur" || $destination=="Boracay" )
{
    $perday=3000;
    $permonth=9000;
    $perhour=125;
    $car=1740;

if($rhr>$phr)
        {
        $total=($rhr)- ($phr);
        $totalhr=$perhour * $total;

        }
    else if($rhr==$phr)
        {    
        $totalhr;
        }
    if($rday>$pday)
        {
        $totald=($rday)-($pday);
        $totalday=$perday * $totald;
        }
    else if($rday==$pday)
        {
        $totalday;
        }

    if($rmonth>$pmonth)
        {
        $totalm=$rmonth-$pmonth;
        $totalmonth=$totalm * $permonth;

        }
    else if($rmonth==$pmonth)
        {
        $totalmonth;
        }
        $rate=$car+$totalhr+$totalday;     
}
if($origin=="NAIA 1" && $vehicle=="Innova" && $destination=="Manila" || $destination=="Cam Sur" || $destination=="Boracay" )
{
    $perday=3000;
    $permonth=9000;
    $perhour=125;
    $car=1740;

if($rhr>$phr)
        {
        $total=($rhr)- ($phr);
        $totalhr=$perhour * $total;

        }
    else if($rhr==$phr)
        {    
        $totalhr;
        }
    if($rday>$pday)
        {
        $totald=($rday)-($pday);
        $totalday=$perday * $totald;
        }
    else if($rday==$pday)
        {
        $totalday;
        }

    if($rmonth>$pmonth)
        {
        $totalm=$rmonth-$pmonth;
        $totalmonth=$totalm * $permonth;

        }
    else if($rmonth==$pmonth)
        {
        $totalmonth;
        }
        $rate=$car+$totalhr+$totalday;     
}
if($origin=="NAIA 1" && $vehicle=="Vans" && $destination=="Manila" || $destination=="Cam Sur" || $destination=="Boracay" )
{
    $perday=3000;
    $permonth=9000;
    $perhour=125;
    $car=1740;

if($rhr>$phr)
        {
        $total=($rhr)- ($phr);
        $totalhr=$perhour * $total;

        }
    else if($rhr==$phr)
        {    
        $totalhr;
        }
    if($rday>$pday)
        { ...

Guys Thanks a lot for the help its now working already..again thanks everyone:)

ok thanks a lot for the advice i'll try it..hope i can make something out of it..

hi i'm not getting it correctly. can you give me an example code.atleast 1 textbox that are already uppercase when you type a word..thanks in advance, coz i can find a way to incorporate it using a textbox.

thanks for the quick reply..i'll give it a shot..

hi i'm just wondering on how can i make all the type text in my textbox all uppercase using php? tnx Alot..

so what do you wanna do with it?

hey i got ot working already!

hi cereal am i doing it correctly?

$sql = mysql_query("select * from sdti where Rnum like '$search'") UNION ("select * from sd where Rnum like '$search'") UNION ("select * from tr where Rnum like '$search'") ;

Hi guys I’m new to this site and i really need a professional help out here. I am trying to make a search form in my page and basically i can search my database already but i need to revised the code because the process of my search form depends on a dropdown menu
which contains the table names in my database basically the searching will depend to the selected service form the dropdown menu. what i want to happen is to eliminate the dropdown menu and make an automatic searching throughout my tables in the database and fetch the necessary data.. thanks in advance

this is the searchform.html

<html>
<body bgcolor="#CCCCCC">
 <form method="post" action="searchresult.php" name="form2">
   <p><img src="images/europcar.jpg" width="560" height="162" /></p>
   <p align="center">Please dont live any blank space while searching</p>
   <p align="center">Search Reservation Number </p>
   <p align="center">
     <input type="text" name="search" size=25 maxlength=25 >   
      <select name="table" size="1">
        <option selected="selected"></option>
        <option value="sd">SelfDrive</option>
         <option value="sdti">SelfDrive texas</option>
        <option value="ch">Carhire</option>
          <option value="chti">Carhire texas</option>
           <option value="cd">Chauffeur Drive</option>
            <option value="cdti">Chauffeur Drive texas</option>
            <option value="pudo">Pick up Drop off</option>
            <option value="pudoti">Pick up Drop off texas</option>

       </select>
     <input type="Submit" name="Submit" value="Submit">
     </p>
 </form>
</body>
 </html>

**this part is the searching
searchresult.php**

<?php
   $table=$_POST['table'];
   $search=$_POST['search'];

 if ($search == "" or $table=="") 
 { 
 echo"<a href='a.html'> back </a>";
 echo "<p>You forgot to enter the reservation number"; 
 exit; 
 } 

$dbhost = 'localhost';
$dbuser = 'europcar_msic';
$dbpass = 'msictran';

$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');

$dbname = 'europcar_msic';
mysql_select_db($dbname);

if ($table=="cd")
{

 $sql = mysql_query("select * from cd where ...