Ahoj lidi prosím vás mohl by mi někdo helpnout potřebuji vyřešit jen jednu část kódu ,ostatní mi fungují a to (smazaní,odeslání do databáze a zobrazení na stránce), ale nejde mi ta změna,data se sice načtou do formu ale neodešlou se do databáze po kliknutí na tlačítko s funkcí submit.
Kód :
<?php
include('pripojeni.php');
$link = mysqli_connect('localhost','root','');
mysqli_set_charset($link, "utf8");
$op='';
$msg='';
if (isset($_POST['op']))
{
$op=$_POST['op'];
}
if (isset($_GET['op']))
{
$op=$_GET['op'];
}
if($op=='send')
{
$day=$_POST['txtday'];
$date=$_POST['txtdate'];
$break=$_POST['txtbreak'];
$main_food=$_POST['txtmain_food'];
$soup=$_POST['txtsoup'];
$a_sql=mysqli_query($conn,"INSERT INTO days_tbl VALUES('','$day','$date','$break','$main_food','$soup')");
}
if ($op=='delete')
{
$id=$_GET['id'];
$delete=mysqli_query($conn,"DELETE FROM days_tbl WHERE day_id =$id ");
}
if ($op=='saveup')
{
$day=$_POST['txtday'];
$date=$_POST['txtdate'];
$break=$_POST['txtbreak'];
$main_food=$_POST['txtmain_food'];
$soup=$_POST['txtsoup'];
$a_sql=mysqli_query($conn,"UPDATE days_tbl SET day='$day',date='$date',break='$break',main_food='$main_food',soup='$soup' WHERE day_id =$id");
}
?>
<html>
<head>
<style>
.prcka{
color:red;
}
.week{
color:red;
position:relative;
float:left;
}
</style>
</head>
<body>
<?php
if ($op=='saveup') {
$id=$_GET['id'];
$row=mysqli_query($conn,"SELECT * FROM days_tbl WHERE day_id='$id'");
$st_row=mysqli_fetch_array($row);
?>
<h2>Změna</h2>
<form method="POST" action='index.php?op=update'>
<table align="center" >
<tr>
<td>Den</td>
<td><input type='text' name='txtday' value='<?PHP echo $st_row['day'] ?>'/></td>
<tr>
<tr>
<td>Datum</td>
<td><input type='text' name='datename' value='<?PHP echo $st_row['date'] ?>'/></td>
<tr>
<tr>
<td>Svačina</td>
<td><input type='text' name='breakname' value='<?PHP echo $st_row['break'] ?>'/></td>
<tr>
<tr>
<td>Hlavní Jídlo</td>
<td><input type='text' name='main_foodname' value='<?PHP echo $st_row['main_food'] ?>'/></td>
<tr>
<tr>
<td>Polévka</td>
<td><input type='text' name='soupname' value='<?PHP echo $st_row['soup'] ?>'/></td>
<tr>
<tr>
<td></td>
<td><input type='submit' name='button'/></td>
<tr>
</table>
</form>
<?php }else{
?>
<h2>Přidání</h2>
<form method="POST" action='index.php?op=send' >
<table align="center" >
<tr>
<td class=prcka>Den</td>
<td><input type='text' name='txtday'/></td>
<tr>
<tr>
<td>Datum</td>
<td><input type='text' name='txtdate'/></td>
<tr>
<tr>
<td>Svačina</td>
<td><input type='text' name='txtbreak'/></td>
<tr>
<tr>
<td>Hlavní Jídlo</td>
<td><input type='text' name='txtmain_food'/></td>
<tr>
<tr>
<td>Polévka</td>
<td><input type='text' name='txtsoup'/></td>
<tr>
<tr>
<td></td>
<td><input type='submit' name='button'/></td>
<tr>
</table>
</form>
<?php } ?>
<?php
$sql=mysqli_query($conn,"SELECT * FROM days_tbl");
while($row=mysqli_fetch_array($sql))
{
echo"
<div class=week>
<p>Den: ".$row['day']."</p>
<p>Datum: ".$row['date']."</p>
<p>Svačina: ".$row['break']."</p>
<p>Hlavní jídlo: ".$row['main_food']."</p>
<p>Polévka: ".$row['soup']."</p>
<a rel="nofollow" href='index.php/?op=saveup&id=".$row['day_id']."'>změnit<a>
<a rel="nofollow" href='index.php/?op=delete&id=".$row['day_id']."'>smazat<a>
</div>
";
}
?>
</body>
</html>