Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <style>
- table tr:nth-child(odd)
- {
- background-color: #3a962c;
- }
- table tr:nth-child(even)
- {
- background-color: #64D453;
- }
- </style>
- </head>
- <body>
- <?php
- $trucks=Array(
- Array("KrAZ","Kremenchuk","Ukraine",Array(
- Array("KrAZ-65055","6x6","330Hp"),
- Array("KrAZ-6130C4","6x6","330Hp"),
- Array("KrAZ-5133H2","4x2","330Hp"),
- Array("KrAZ-7140H6","8x6","400Hp")
- )),
- Array("EBIAM","Thessaloniki","Greece",Array(
- Array("EBIAM MVM","4x4","86Hp")
- )),
- Array("KaMAZ","Naberezhnye Chelny","Tatarstan",Array(
- Array("KAMAZ 54115","6x4","240Hp"),
- Array("KAMAZ 6560","8x8","400Hp"),
- Array("KAMAZ 5460","8x8","340Hp")
- )),
- Array("LIAZ","Rynovice","Czechoslovakia",Array(
- Array("LIAZ 706 RT","2x4","160Hp")
- )),
- Array("IRUM","Brasov","Romania",Array(
- Array("TAF 690","2x4","90Hp")
- )),
- Array("MAZ","Minsk","Belarus",Array(
- Array("MAZ 535","8x8","375Hp"),
- Array("MAZ 7310","8x8","525Hp"),
- Array("MAZ 7907","4x12","1250Hp"),
- Array("MAZ 6317","6x6","425Hp"),
- Array("MAZ 6430","6x6","360Hp"),
- Array("MAZ 5551","4x2","160Hp")
- )),
- Array("BelAz","Zohodino","Belarus",Array(
- Array("Belaz 75600","4x4","3400Hp")
- )),
- Array("Oshkosh","Oshkosh","USA",Array(
- Array("Oshkosh P-15","8x8","840Hp"),
- Array("Oshkosh MK-36","6x6","425Hp")
- )),
- Array("Tatra","Koprivnice","Czechoslovakia",Array(
- Array("Tatra T 813","4x4","266Hp"),
- Array("Tatra T 815","10x10","436Hp"),
- ))
- );
- $countries=Array();
- foreach($trucks as $truck){
- // Is the key $truck[2] i.e. the country name set in the array $countries or not?
- // If not this means that this country does not exist in the array and therefore should be added to the array
- // This creates a list of countries without duplicates
- if(!isset($countries[$truck[2]])){
- $countries[$truck[2]]=$truck[2];
- }
- }
- // For each counry create an option tag for the select named country
- echo "<form method='post' action='uppgift1b.php'>
- <select name='country' onchange='this.form.submit()'>";
- echo "<option> </option>"; // Empty starting choice
- foreach($countries as $country)
- {
- echo "<option>". $country . "</option>";
- }
- echo "</select></form>";
- if(isset($_POST['country'])) /* If our select-box is set we create a table with the chosen country */
- {
- foreach($trucks as $printTruck)
- {
- if($_POST['country'] == $printTruck[2])
- {
- echo "<table id=\"truckTable\" border=\"1\" style=\"margin-top: 10px; margin-bottom: 10px;\">";
- echo "<tr><th>Modelname: " . $printTruck[0] . "</th><th>City: " . $printTruck[1] . "</th><th>Country: " . $printTruck[2] . "</th></tr>" ;
- echo "<tr><th>Name:</th><th>Wheel:</th><th>Horse Power:</th></tr>";
- foreach($printTruck[3] as $printDatas)
- {
- echo "<tr>";
- foreach($printDatas as $printData)
- {
- echo "<td>" . $printData . "</td>";
- }
- echo "</tr>";
- }
- echo "</table>";
- }
- }
- }
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement