This is an old revision of the document!
Del c - uppgift 9
<?php include ("head.php"); if (isset($_POST['t1'])){ if ($_POST['t2'] > $_POST['t1']){ //Är andra talet större än det första? Byt i så fall plats. $temp = $_POST['t1']; $_POST['t1'] = $_POST['t2']; $_POST['t2'] = $temp; } if ($_POST['t3'] > $_POST['t2']){ //Är tredje talet större än det andra? Byt i så fall plats. $temp = $_POST['t2']; $_POST['t2'] = $_POST['t3']; $_POST['t3'] = $temp; } if ($_POST['t2'] > $_POST['t1']){ //Testa igen det andra och första talen. (Förändring kan ha skett ovan) $temp = $_POST['t1']; $_POST['t1'] = $_POST['t2']; $_POST['t2'] = $temp; } echo "Talen störst - minst: "; echo $_POST['t1']." - ".$_POST['t2']." - ".$_POST['t3']; } echo "<br><br>"; ?> <form method = "POST"> Tal1: <input type = "text" name = "t1"> Tal2: <input type = "text" name = "t2"> Tal3: <input type = "text" name = "t3"> <input type = "submit" value="Sortera"> </form> <?php include ("foot.php"); ?>