this code will display all courses user has
<h1>YOUR COURSES</h1> <form action="delete.php" method="POST"><ol>
<?php
$con=mysqli_connect("localhost","FYP","123","FYP");
$sql= mysqli_query($con, "SELECT C_Code FROM F_COURSES WHERE F_ID=".$_SESSION['userid']);
while($row = mysqli_fetch_array($sql)){
echo "<li name='course'>".$row['C_Code']."<input type='submit' value='Delete'>";}
?></ol></form>
I need when user click on delete button that course delete from F_courses
<?php
session_start();
if (! empty($_SESSION['logged_in']))
{
$con=mysqli_connect("localhost","FYP","123","FYP");
$id=$_SESSION['userid'];
$course=$_POST["course"];
$sql="DELETE FROM F_COURSES WHERE F_ID='$id' AND C_Code='$course'";
mysqli_query($con,$sql);
header ("location: mycourses.php");
}
else
{
echo 'You are not logged in. <a href="login.html">Click here</a> to log in.';
}
Could you please help me how to correct my code
Thank you