Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8" />
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
- <title>Page Title</title>
- <meta name="viewport" content="width=device-width, initial-scale=1">
- <link rel="stylesheet" type="text/css" media="screen" href="main.css" />
- <script src="main.js"></script>
- </head>
- <body>
- <?php
- $file = fopen("cars.txt", "r");
- $marke = array();
- $zemlje = array();
- while(!feof($file)){
- $red = explode("\t", fgets($file));
- if(!in_array($red[1], $marke)){
- array_push($marke, $red[1]);
- }
- if(!in_array($red[6], $zemlje)){
- array_push($zemlje, $red[6]);
- }
- }
- if(!$_POST){
- ?>
- <form method="post" action="">
- <select name="marka">
- <?php
- foreach($marke as $m){
- echo '<option value="'.$m.'">'.$m.'</option>';
- }
- ?>
- </select>
- <select name="zemlja">
- <?php
- foreach($zemlje as $z){
- echo '<option value="'.$z.'">'.$z.'</option>';
- }
- ?>
- </select>
- <input type="submit">
- </form>
- <?php
- }
- if($_POST){
- $file = fopen("cars.txt", "r");
- $brojac = 0;
- $polje = [];
- $zemlja = $_POST['zemlja'];
- $marka = $_POST['marka'];
- echo '<table>';
- while(!feof($file)){
- $red = explode("\t", fgets($file));
- if($red[1] == $marka){
- if($red[6] == $zemlja){
- $brojac++;
- echo '<tr><td>'.$red[2].'</td><td>('.$brojac.')</td></tr>';
- }
- }
- }
- echo '</table>';
- //var_dump($polje);
- }
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement