Sunday, June 7, 2015

Cars Collections Information System in PHP and XML

A simple application that I wrote in PHP and XML that will give information to the user about the classic car collections in the past. The data is being stored in XML file  and I retrieve the records using PHP as my programming language.

If you have some questions please send me an email at jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

People here in the Philippines can reach me at my mobile number 09173084360.

Thank you very much and Happy Programming.






Sample Program Output

index.php


<!-- Selecting a value in PHP and XML           -->
<!-- June 7, 2015   Sunday                      -->
<!-- Written By: Mr. Jake R. Pomperada, MAED-IT -->
<!-- Email Address: jakerpomperada@gmail.com    -->
<!--              : jakerpomperada@yahoo.com    -->
<html>
<title>Car Collection in PHP and XML
</title>
<style>
h1 {
    font-family:arial;
color:blue;
};

</style>

<body bgcolor="yellow">
<br><br>
<h1>
Car Collection in PHP and XML
</h1>
<form method="post" action="">
<select id="select" class="select" name="filter1" style="text-align:center;">
<option value="1" <?php if(@$_POST['filter1'] == '1') { echo 'selected = \"selected\"'; } ?>>Car Series One</option>
<option value="2"  <?php if(@$_POST['filter1'] == '2') { echo 'selected = \"selected\"'; } ?>>Car Series Two</option>
</select>
<input type="submit" id="submit" name="submit" value="ok" title="Click here to select your choice.">
</form>
<br>
<?php 
if(isset($_POST['submit'])){

if($_POST['filter1'] == "1")
{
$xml = simplexml_load_file("car1.xml");

         foreach($xml->children() as $automobile)
              {
                  echo "<font color='blue' face='arial' size='3'>Car Name   : ".$automobile->name."<br />";
                  echo "Year    : ".$automobile->year." <br />";
 echo "Price  : ".$automobile->price." <br />";
        echo " Description : ".$automobile->description." <br /> </font>";
echo "<br><br>";
                }             
        }

else if ($_POST['filter1'] == "2")
{
$xml = simplexml_load_file("car2.xml");
       
  foreach($xml->children() as $automobile)
              {
               echo "<font color='blue' face='arial' size='3'>Car Name   : ".$automobile->name."<br />";
               echo "Year    : ".$automobile->year." <br />";
  echo "Price  : ".$automobile->price." <br />";
      echo " Description : ".$automobile->description." <br /> </font>";
   echo "<br><br>";
               
             }
  }

}
?>

</body>
</html>


car1.xml

<?xml version="1.0"?>
<cars>
   <automobile id="1">
      <name>Studebaker President Eight Roadster </name>
      <year> 1929 </year>
       <price>$1,895</price>
       <description>
   Studebaker 1929 President Eight Roadster seats two
in the comfortable front seats and two in the Rumble
, 115 Horsepower engine, hydraulic shock absorbers, wire wheels,
spare tire and bumpers are additional 
to the price. 
   </description>
   </automobile>

   <automobile id="2">>
      <name>Chevrolet</name>
      <year> 1924 </year>
       <price>$525.00</price>
       <description>
   By the middle of the decade Chevrolet had joined the auto mass production 
era and although the cars were more expensive than Ford's at the time many of 
those things that cost extra on the Ford were included, the basic specs were Standard 
Transmission with 3 forward and 1 reverse gear, Standard Electrical System which 
included electric starter, electric lights front and rear, large radiator and fan, 
speedometer, ammeter, oil pressure gauge,choke pull, starting switch, plus an extra tire 
rim was included mounted on the rear of the car
   </description>
   </automobile>
   
    <automobile id="3">>
      <name>Buick Marquette </name>
      <year> 1930</year>
       <price>$965.00</price>
       <description>
 The Buick Marquette features a 67.5 horsepower engine that 
 races from 0 to 60 in just 31 seconds. The Buick Marquette offers 
 easy vibration free motoring at 70 MPH, also featuring 4 wheel brakes 
 working on 12 inch drums, 4 hydraulic shock absorbers ensure a 
 smooth ride over all surfaces. Bodies are manufactured by Fisher 
   </description>
   </automobile>
   
   <automobile id="4">>
      <name>Gray Motor Company Coach </name>
      <year> 1923</year>
       <price>$785</price>
       <description>
1923 Gray Motor Company Coach features a four cylinder engine, 
3 speed transmission, lightening ignition from Westinghouse, 
4 wheel shock absorbing springs,comes in 4 options starting at $495 for
the Roadster to the 4 door sedan costing $835.00 
   </description>
   </automobile>
     

</cars>

car2.xml

<?xml version="1.0"?>
<cars>
   <automobile id="1">
      <name>Dodge Brothers De-Luxe Sedan   </name>
      <year> 1926</year>
       <price>$1,075</price>
       <description>
   Dodge Brothers auto's are known for their top quality materials used 
in each and every auto with the finest Chrome Vanadium used from the Axles 
to the engine, and Mohair Interior of the finest quality offering long life 
and dependability for your purchase. 
   </description>
   </automobile>

   <automobile id="2">>
     <name>Cadillac 90 Degree </name>
      <year> 1927</year>
       <price>$2,995</price>
       <description>
   Cadillac Prestige Pointing the way to Luxury, Distinction and motor car value 
that brings abiding satisfaction.
   </description>
   </automobile>
   
    <automobile id="3">
       <name>Chrysler 75 Roadster </name>
      <year> 1928</year>
       <price>$1,555</price>
       <description>
 The new Chrysler 75 Roadster for 1928, one the most attractive cars of 
 our times made by master craftsmen entering a new era in design and craftsmanship. 
   </description>
   </automobile>
   
   <automobile id="4">
     <name>Horse Drawn Auto Seat Top Buggy  </name>
      <year> 1905</year>
       <price> $86.70 </price>
       <description>
   I have included this example because it shows how traditional 
horse drawn carriage manufacturers were trying to survive, one
of the most interesting selling points for this carriage was that
the wheel base size was the same as most of the smaller autos of the 
day 4ft 8 inches, and if you look the sitting position and layout was
very similar although higher off the ground. 
  </description>
      </automobile>
</cars>


No comments:

Post a Comment