hi
im working on my school project, im php beginner so some obvious things might not be so obvious for me…
so i have my single item page which im getting from sql by get method
item page displays fine, but once i try to update some columns, does not work
i used update code before (not with get method) and worked fine
i am sure im missing something there but spent few days and still nothing
any suggestion appreciated
attached the code
and also new.php (1.6 KB)
there is the code
<?php include 'connection.php';
if(isset($_POST['save']))
{
$UpdateQuery = "UPDATE Training SET name='$_POST[name]', price='$_POST[price]', days='$_POST[days]', units='$_POST[units]', info='$_POST[info]', outcome='$_POST[outcome]'
WHERE name ='$_POST[hidden]'";
mysqli_query($con, $UpdateQuery);
print "The training has been updated<br>Visit <a href=''>website</a>";
}
$result= mysqli_query($con, "SELECT * FROM Training WHERE id='$id'");
$id=$_GET['id1'];
$sql="SELECT * FROM Training WHERE id='$id'";
$query=mysqli_query($con,$sql);
while($row=mysqli_fetch_array($query,MYSQLI_ASSOC)){
echo "<form action=item.php?id=".$row['id']." method=post>";
echo "Name: <br>";
echo "<textarea name='name' cols='100' rows='1' >".$row['name']."</textarea> <br><br>";
echo "<input type=hidden name=hidden value= '". $row['name']."'> ";
echo "Price: <br>";
echo " <input type=text name='price' value= '".$row['price']."'> <br><br>";
echo "Days: <br>";
echo "<textarea name='days' cols='100' rows='3' >".$row['days']."</textarea> <br><br>";
echo "Units: <br>";
echo "<textarea name='units' cols='100' rows='3' >".$row['units']."</textarea> <br><br>";
echo "Course info:<br> ";
echo "<textarea name='info' cols='100' rows='10' >".$row['info']."</textarea> <br><br>";
echo "Outcome: <br>";
echo "<textarea name='outcome' cols='100' rows='4' >".$row['outcome']."</textarea> <br><br>";
echo "<input type=submit name=save value= 'save'" ;
echo '</form>';
}
?>
new.php (1.6 KB)