Witam, mam taki problem mam stronę w caseach i chce zrobić coś takiego żeby jak wyśle formularz to on wyświetla się pod tym formularzem i po kliknięciu w nazwę linku np. id sortuje w zależności ile razy wcisnę sortuję wtedy asc lub desc i problem pojawia się wtedy gdy ten skrypt umieszczam w casie bo gdy jest on na normalnej stronie to wszystko działa. Tutaj kod strony w html i php.
<center><a href="url"><b style="color: white;">Link
</b></a> <a href="url"><b style="color: white;">Link
</b></a> <a href="url"><b style="color: white;">Link
</b></a> <a href="url"><b style="color: white;">Link
</b></a> <a href="url"><b style="color: white;">Link
</b></a></center> <div class=menu><b style="color: white;">MENU
</b></div> <a href="index.php?akcja=strona">Strona główna
</a> <br> <a href="index.php?akcja=formularz">Formularz
</a> <br> <a href="index.php?akcja=yt">Odtwarzacz YT
</a> <br> <a href="index.php?akcja=obiekt">Odtwarzacz Obiekt
</a> <Br> <a href="index.php?akcja=video">Odtwarzacz Video
</a> <Br> <a href="url">Link
</a> <br> <a href="url">Link
</a> <br> <a href="url">Link
</a> <Br> <a href="url">Link
</a> <br> <a href="url">Link
</a> <br>
switch($_GET['akcja'])
{
case('strona'):
{
wyswietl_strona();
}
break;
case('formularz'):
{
wyswietl_formularz();
}
break;
case('yt'):
{
wyswietl_yt();
}
break;
case('obiekt'):
{
wyswietl_obiekt();
}
break;
case('video'):
{
wyswietl_video();
}
break;
default:
{
wyswietl_strona();
}
break;
}
function wyswietl_strona()
<br>
<b><h1> WITAJ NA STRONIE GŁÓWNEJ! <h1></b>
'; }
function wyswietl_formularz()
'
<center> <form action="is.php" method="post">
<div class="form-group">
<label>Imie</label>
<input type="text" name="imie" class="form-control">
</div>
<div class="form-group">
<label>Nazwisko</label>
<input type="text" name="nazwisko" class="form-control">
</div>
<input type="submit" name="submit" value="Submit">
</form>
'
;
$servername='localhost';
$username='root';
$password='';
$dbname = "formularz";
$conn=mysqli_connect($servername,$username,$password,"$dbname");
if(!$conn){
}
if(isset($_POST['submit'])) {
$imie = $_POST['imie'];
$nazwisko = $_POST['nazwisko'];
$sql = "INSERT INTO users (imie,nazwisko)
VALUES ('$imie','$nazwisko')";
if (mysqli_query($conn, $sql)) {
echo "Zostałeś zapisany"; } else {
echo "Error: " . $sql . ":-" . mysqli_error
($conn); }
mysqli_close($conn);
}
$hostName = "localhost";
$username = "root";
$password = "";
$dbname = "formularz";
$mysqli = new mysqli($hostName, $username, $password, $dbname);
$orderBy = !empty($_GET["orderby"]) ?
$_GET["orderby"] : "name"; $order = !empty($_GET["order"]) ?
$_GET["order"] : "asc";
$sqll = "SELECT * FROM users ORDER BY " . $orderBy . " " . $order;
$result = $mysqli->query($sqll);
$idOrder = "asc";
$imieOrder = "asc";
$nazwiskoOrder = "asc";
if($orderBy == "id" && $order == "asc") {
$idOrder = "desc";
}
if($orderBy == "imie" && $order == "asc") {
$imieOrder = "desc";
}
if($orderBy == "nazwisko" && $order == "asc") {
$nazwiskoOrder = "desc";
}
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error); }
echo "<table border=\"1\"><tr>"; echo "<td><a href='?orderby=id&order=".$idOrder."'>ID</a></td>"; echo "<td><a href='?orderby=imie&order=".$imieOrder."'>Imie</a></td>"; echo "<td><a href='?orderby=nazwisko&order=".$nazwiskoOrder."'>Nazwisko</a></td>";
while($row = mysqli_fetch_assoc($result)){
echo "<td>" . $row['id'] . "</td>"; echo "<td>" . $row['imie'] . "</td>"; echo "<td>" . $row['nazwisko'] . "</td>"; }
$conn->close();
}
function wyswietl_yt()
'
<h1><b>Odtwarzacz YT</b></h1>
<iframe width="730" height="370" src="https://www.youtube.com/embed/fb5ELWi-ekk" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>
'; }
function wyswietl_obiekt()
'
<h1><b>Odtwarzacz YT</b></h1>
<object data="zwiastun.mp4" width="720px" height="360px"> </object>
'; }
function wyswietl_video()
'
<h1><b>Odtwarzacz Video</b></h1>
<video width="700" height="330" src="zwiastun.mp4" autoplay muted controls >Zwiastun Jurrasic Park</video>
'; }