Have a website that i am developing http://www.wheels4rent.net and need help with PHP. when the dates etc and location is entered i have a deep link into another site and i have done this with PHP. This displays cars etc and prices. However i want to have a "book" button in the list_car.php page next to price of cars so that when this is selected it will give customer another page to book but unsure how to do this. The <book> section i have in XML generated from another site and it is CDATA i need to know how to create a button with the CDATA info within as each car will have different CDATA info within the "book" section. Please assist

Member Avatar for diafol

Could you post your code?

ok i have the website www.wheels4rent.net/test00.html. when selected pick up locations and date etc...when 'go' is selected the car hire date and car images and cost..etc are present from list_car.php the code as below

<?php
//ini_set("disable_functions",null);
//phpinfo();

$string="http://www.thrifty.co.uk/cgi-bin/gen5?runprog=thxml&xsrc=7qhfqou3&mode=quote";
$string.="&xloc=".$_REQUEST["loccode"];
$string.="&xpuyear=".substr($_REQUEST["pu_month"],0,4);
$string.="&xpumonth=".substr($_REQUEST["pu_month"],4);
$string.="&xpuday=".$_REQUEST["pu_day"];
$string.="&xputime=".$_REQUEST["pu_time"];
$string.="&xdbyear=".substr($_REQUEST["db_month"],0,4);
$string.="&xdbmonth=".substr($_REQUEST["db_month"],4);
$string.="&xdbday=".$_REQUEST["db_day"];
$string.="&xdbtime=".$_REQUEST["db_time"];
$string.="&xclass=".$_REQUEST["vehicle_type"];

/*
function get_data($url)
{
  $ch = curl_init();
  $timeout = 5;
  curl_setopt($ch,CURLOPT_URL,$url);
  curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
  curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
  $data = curl_exec($ch);
  curl_close($ch);
  return $data;
}
echo get_data($string);


function proxy_url($proxy_url)
{
    $proxy_name = '127.0.0.1';
    $proxy_port = 4001;
    $proxy_cont = '';

    $proxy_fp = fsockopen($proxy_name, $proxy_port);
    if (!$proxy_fp)    {return false;}
    fputs($proxy_fp, "GET $proxy_url HTTP/1.0\r\nHost: $proxy_name\r\n\r\n");
    while(!feof($proxy_fp)) {$proxy_cont .= fread($proxy_fp,4096);}
    fclose($proxy_fp);
    $proxy_cont = substr($proxy_cont, strpos($proxy_cont,"\r\n\r\n")+4);
    return $proxy_cont;
} 

echo proxy_url($string);*/


function XML2Array ( $xml , $recursive = false )
{
    if ( ! $recursive )
    {
        $array = simplexml_load_string ( $xml ) ;
    }
    else
    {
        $array = $xml ;
    }
   
    $newArray = array () ;
    $array = ( array ) $array ;
    foreach ( $array as $key => $value )
    {
        $value = ( array ) $value ;
        if ( isset ( $value [ 0 ] ) )
        {
            $newArray [ $key ] = trim ( $value [ 0 ] ) ;
        }
        else
        {
            $newArray [ $key ] = XML2Array ( $value , true ) ;
        }
    }
    return $newArray ;
}

function disp_date($str)
{
$y=substr($str,0,4);
$m=substr($str,4,2);
$d=substr($str,6,2);
//echo $y."-".$m."-".$d;
return date("M d, Y",strtotime($y."-".$m."-".$d));
}

$handle = fopen($string, "r");
$xml_string="";
// If there is something, read and return
if ($handle) {
    while (!feof($handle)) {
        $buffer = fgets($handle, 4096);
        $xml_string.=$buffer;
    }
    fclose($handle);
}

//$xmlDoc = new DOMDocument();
$xmlDoc=simplexml_load_string ( $xml_string ) ;

//print_r($xmlDoc);

echo "Zipcode: ".$xmlDoc->hire->loccode."<br>Location Name: ".$xmlDoc->hire->locname."<br>Pickup Time: ".disp_date($xmlDoc->hire->pickupdate)." ".$xmlDoc->hire->pickuptime."<br>Dropback Time: ".disp_date($xmlDoc->hire->dropbackdate)." ".$xmlDoc->hire->dropbacktime."<br>";

echo "<table border=1 style='font:12px verdana' cellspacing=0 cellpadding=3><tr><td>Car Type</td><td>Description</td><td>Rate</td></tr>";
foreach($xmlDoc->car as $car)
{
echo "<tr><td width=150px><img src='".$car->carimage."' align='right' style='padding:5px; width:64px'><b>".$car->cartype."</b><br>".$car->carsipp."<br>".$car->transmission."</td><td><b>".$car->carexample."</b></td><td><b>&pound;".$car->price."/day</b><br>Unlimited Miles</td></tr>";
}
echo "</table>";
?>

What i am missing and require is the CDAT which is in the <book> section and for example please see below on different CDATA as i need this info for final booking which will go to thriftys booking page although i still want my logos to appear on my web page if possible. below is info from thrifty but i cannot seem to have a "book now" button and link to final booking page???


You can get a quotation with a call like this: location UK001 (Heathrow) 10/10/2011 09:00 - 12/10/2011 10:00 Manual cars only
http://www.thrifty.co.uk/cgi-bin/gen5?runprog=thxml&xsrc=7qhfqou3&mode=quote&xloc=UK001&xpuyear=2011&xpumonth=10&xpuday=10&xputime=09:00&xdbyear=2011&xdbmonth=10&xdbday=12&xdbtime=10:00&xclass=M xclass can be left blank for all, or
M - manual
A - automatic
B - estates and 4x4
P - people carriers
I - minibus
Z - prestige
V - vans and trucks (Heathrow doesn't have these)
X - everything except vans/trucks/minibuses
If xlocdrop is given it should send an appropriate location code (same field codes as used for loccode) eg xlocdrop=UK002
You should use the location call to decide whether this one-way is permitted. ie UK002 should have onewayend=Y
and UK001 should have onewaystart=Y
The xml returns the following formatted reply with a deeplink within the <book> section which jumps in at the quote stage at www.thrifty.co.uk
<Quote>
- <hire>
<loccode>UK001</loccode>
<locname>HEATHROW AIRPORT</locname>
<pickupdate>20111010</pickupdate>
<pickuptime>09:00</pickuptime>
<dropbackdate>20111012</dropbackdate>
<dropbacktime>10:00</dropbacktime>
</hire>
- <car>
<carimage> http://www.thrifty.co.uk/thrifty/images/carslarge/quotes/312721294241850.jpg </carimage>
<cartype>Full Size</cartype>
<carsipp>SDMR</carsipp>
<carexample>VW Passat 2.0 5dr CD Player A/C Auxilliary Port - or similar</carexample>
<cardoors>4</cardoors>
<carpax>5</carpax>
<carsuitcases>2</carsuitcases>
<carbags>3</carbags>
<carsmallbags>0</carsmallbags>
<transmission>Manual</transmission>
<currencyid>GBP</currencyid>
<price>146.69</price>
- <book>
- <![CDATA[

www.thrifty.co.uk/cgi-bin/gen5?runprog=thxml&xsrc=7qhfqou3&mode=book&x=hoiLhomHgdy3lNDt74WsjKWal5uCm8nDwt7B3N61nLyVo6m8%2B%2FL0n7LKtp6OhYDb093b0u%2B%2BubyEsZaUg5DIxMPFwMPfromMtIios%2Fr595inpp621oSP2tnV3NPUv4O4hbmB6emmzcfFmpithp6FjJ%2BJi9bdl7m1q%2Fj1%2B%2Fyfss2Gh4jVu5WWhoyLq9HgnLSzkqSBnZ2fkJiUrZuJnYvWoZe4qL%2F0%2B47xvfOJ2cTflNTQ08rZnu7VoaKn7IXKi6aZmZCQg52fzd%2Bo3ts

]]>
</book>
</car>
Regards,

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.