Advertisement
Guest User

Untitled

a guest
May 27th, 2015
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.28 KB | None | 0 0
  1. <html>
  2. <head>
  3. <style>
  4.  
  5. table tr:nth-child(odd)
  6. {
  7.  
  8. background-color: #3a962c;
  9. }
  10.  
  11. table tr:nth-child(even)
  12. {
  13.  
  14. background-color: #64D453;
  15. }
  16.  
  17. </style>
  18. </head>
  19. <body>
  20.  
  21. <?php
  22.  
  23. $trucks=Array(
  24. Array("KrAZ","Kremenchuk","Ukraine",Array(
  25. Array("KrAZ-65055","6x6","330Hp"),
  26. Array("KrAZ-6130C4","6x6","330Hp"),
  27. Array("KrAZ-5133H2","4x2","330Hp"),
  28. Array("KrAZ-7140H6","8x6","400Hp")
  29. )),
  30. Array("EBIAM","Thessaloniki","Greece",Array(
  31. Array("EBIAM MVM","4x4","86Hp")
  32. )),
  33. Array("KaMAZ","Naberezhnye Chelny","Tatarstan",Array(
  34. Array("KAMAZ 54115","6x4","240Hp"),
  35. Array("KAMAZ 6560","8x8","400Hp"),
  36. Array("KAMAZ 5460","8x8","340Hp")
  37. )),
  38. Array("LIAZ","Rynovice","Czechoslovakia",Array(
  39. Array("LIAZ 706 RT","2x4","160Hp")
  40. )),
  41. Array("IRUM","Brasov","Romania",Array(
  42. Array("TAF 690","2x4","90Hp")
  43. )),
  44. Array("MAZ","Minsk","Belarus",Array(
  45. Array("MAZ 535","8x8","375Hp"),
  46. Array("MAZ 7310","8x8","525Hp"),
  47. Array("MAZ 7907","4x12","1250Hp"),
  48. Array("MAZ 6317","6x6","425Hp"),
  49. Array("MAZ 6430","6x6","360Hp"),
  50. Array("MAZ 5551","4x2","160Hp")
  51. )),
  52. Array("BelAz","Zohodino","Belarus",Array(
  53. Array("Belaz 75600","4x4","3400Hp")
  54. )),
  55. Array("Oshkosh","Oshkosh","USA",Array(
  56. Array("Oshkosh P-15","8x8","840Hp"),
  57. Array("Oshkosh MK-36","6x6","425Hp")
  58. )),
  59. Array("Tatra","Koprivnice","Czechoslovakia",Array(
  60. Array("Tatra T 813","4x4","266Hp"),
  61. Array("Tatra T 815","10x10","436Hp"),
  62. ))
  63. );
  64.  
  65. $countries=Array();
  66.  
  67. foreach($trucks as $truck){
  68. // Is the key $truck[2] i.e. the country name set in the array $countries or not?
  69. // If not this means that this country does not exist in the array and therefore should be added to the array
  70. // This creates a list of countries without duplicates
  71. if(!isset($countries[$truck[2]])){
  72. $countries[$truck[2]]=$truck[2];
  73. }
  74. }
  75.  
  76. // For each counry create an option tag for the select named country
  77. echo "<form method='post' action='uppgift1b.php'>
  78. <select name='country' onchange='this.form.submit()'>";
  79.  
  80. echo "<option> </option>"; // Empty starting choice
  81.  
  82. foreach($countries as $country)
  83. {
  84. echo "<option>". $country . "</option>";
  85. }
  86.  
  87. echo "</select></form>";
  88.  
  89.  
  90.  
  91.  
  92. if(isset($_POST['country'])) /* If our select-box is set we create a table with the chosen country */
  93. {
  94.  
  95.  
  96. foreach($trucks as $printTruck)
  97. {
  98.  
  99.  
  100. if($_POST['country'] == $printTruck[2])
  101. {
  102. echo "<table id=\"truckTable\" border=\"1\" style=\"margin-top: 10px; margin-bottom: 10px;\">";
  103.  
  104. echo "<tr><th>Modelname: " . $printTruck[0] . "</th><th>City: " . $printTruck[1] . "</th><th>Country: " . $printTruck[2] . "</th></tr>" ;
  105. echo "<tr><th>Name:</th><th>Wheel:</th><th>Horse Power:</th></tr>";
  106.  
  107.  
  108. foreach($printTruck[3] as $printDatas)
  109. {
  110.  
  111. echo "<tr>";
  112.  
  113. foreach($printDatas as $printData)
  114. {
  115. echo "<td>" . $printData . "</td>";
  116. }
  117.  
  118. echo "</tr>";
  119. }
  120.  
  121. echo "</table>";
  122. }
  123. }
  124.  
  125.  
  126.  
  127. }
  128.  
  129. ?>
  130.  
  131. </body>
  132.  
  133. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement