avatar
Untitled

Guest 44 15th Nov, 2019

MARKUP 3.13 KB
                                           
                         <html lang="pl">
<head>
<meta charset="utf-8">
<title>Rzut Oszczepem</title>
<link rel="stylesheet" href="XDDD.css" type="text/css">
</head>
<body>
<div id="baner">
<h1>Klub sportowy: rzut oszczepem</h1>

</div>
<div id="glowny">
<h1>Nasz rekord:<?php 
			$connect= mysqli_connect('localhost','root','','sportowcy');
			$ask = "SELECT MAX(`wyniki`.`wynik`) FROM `wyniki` WHERE `wyniki`.`dyscyplina_id` = 3";
			$result = mysqli_query($connect,$ask);
			while ($line=mysqli_fetch_row($result)) 
			{
				echo $line[0]. 'm';
			}

			mysqli_close($connect) 
			?></h1>

<table>
	<?php
			
			function is_even($number){
				return $number % 2 == 0;
			}

			function print_average_result($sportsman_id){
				global $connect, $average_results_string_query;
				$query = sprintf($average_results_string_query, $sportsman_id);
				$resource = mysqli_query($connect, $query);
				$sportsman_average_results =  mysqli_fetch_row($resource);
				
				echo '<p>Średni wynik: ' .$sportsman_average_results[0]. '</p>';
			}

			function print_sportsman($current_record){
				echo '<td>'.$current_record['imie'].' '.$current_record['nazwisko'];
				echo '<br/>';
				print_average_result($current_record['id']);
				echo '</td>';
			}

			$connect= mysqli_connect('localhost','root','','sportowcy');
			$sportsmen_string_query = "SELECT `sportowiec`.`id`, `sportowiec`.`imie`, `sportowiec`.`nazwisko` FROM `sportowiec`";			
			$average_results_string_query = "SELECT AVG(`wyniki`.`wynik`) FROM `wyniki` where `wyniki`.`sportowiec_id` = %d and dyscyplina_id = 3";
			$sportsmen_query_resource = mysqli_query($connect, $sportsmen_string_query);
			$row_closed = False;
			$current_cell_number = 0;

			while($current_record = mysqli_fetch_assoc($sportsmen_query_resource)){
				if(is_even($current_cell_number)){
					echo '<tr>';
					print_sportsman($current_record);
					$row_closed = False;
				} else {
					print_sportsman($current_record);
					echo '</tr>';
					$row_closed = True;
				}

				$current_cell_number++;
			}

			if(!$row_closed){
				echo '</tr>';
			}

			mysqli_close($connect);
		?>
</table>
</div>
<div id="stopa">
<p>Klub sportowy: <br> Strone opracował:0000000</p>

</div>
</body>
</html>








body{
	font-family:;
	margin: 0px;
	padding: 0px;
}
#baner{
background:#773D24;
color:white;
text-align:center;
padding:20px;
	width:100%;
	float:left;
	
}
#glowny{
	background:#B97E65;
	height:600px;
	width:100%;
	float:left;
}
#stopa
{
background:#773D24;
color:white;
text-align:center;
padding:20px;
	width:100%;
	float:left;

}
p{
	text-align:center;
}
table
{
	width: 80%;
	border-spacing:30px;
	

}

tr, td, th
{
	background-color: #DEAD98;
	padding:30px;
}
                      
                                       
To share this paste please copy this url and send to your friends
RAW Paste Data
Recent Pastes
Ta strona używa plików cookie w celu usprawnienia i ułatwienia dostępu do serwisu oraz prowadzenia danych statystycznych. Dalsze korzystanie z tej witryny oznacza akceptację tego stanu rzeczy.
Wykorzystywanie plików Cookie
Jak wyłączyć cookies?
ROZUMIEM