I'm trying to update records in my table, but I'm not sure where I'm missing to mention my indexes in the code. I do believe that my connection is correct, although it should fetch indexes then. I've done the same for insert function for connecting the table, everything works.
This is my update.php
<?php
$connect = mysqli_connect("localhost", "root", "", "produktai");
{
$sql = "UPDATE dazai SET sandely='" . $_POST['sandely'] ."' WHERE id='" . $_POST['id'] ."'";
if(!mysqli_query($connect,$sql))
{
echo "pakeista";
}
else {
echo "nepakeista" . mysqli_error($connect);
}
}
header("refresh:10; url=Dazai.php");
?>
Ok, so I modified my main.php into this. I'm getting this error
Array ( [sandely] => 0 [Keisti] => Keisti ) What could be wrong. The 0 changes to whatever digit i put in.
<div class="prekiu_lentele">
<table class="lenetele_prekems">
<form action="update.php" method="post">
<tr>
<th>ID</th>
<th width="30%">Prekes pavadinimas</th>
<th>Gamintojas</th>
<th>Spalva</th>
<th>Kiekis</th>
<th>Blizgumas</th>
<th width="10%">Kaina</th>
<th>Kategorija</th>
<th width="20%">Kiekis sandelyje</th>
<th>Ištrinti</th>
<th width="20%">Pakeisti</th>
</tr>
</div>
<?php
$query = "SELECT * FROM dazai ORDER BY id ASC";
$result = mysqli_query($connect, $query);
if(mysqli_num_rows($result) > 0)
{
while($row = mysqli_fetch_array($result))
{
?>
<tr>
<td><?php echo $row['id'];?></td>
<td><?php echo $row['pavad'];?></td>
<td><?php echo $row['Gamintojas'];?></td>
<td><?php echo $row['Spalva'];?></td>
<td><?php echo $row['Kiekis'];?></td>
<td><?php echo $row['Blizgumas'];?></td>
<td><?php echo $row['Kaina'];?>€</td>
<td><?php echo $row['Kategorija'];?></td>
<td><input type="text" style="width: 50px; margin-right:10px;" name="sandely" value="<?php echo $row['sandely'];?> "</td>
<td><a href="delete.php?recordID=<?php echo $row['id'];?>">X</a>
<td><input type="submit" name="Keisti" value="Keisti" /></td>
</tr>
</div>
</form>