I just made a PHP script to retrieve entry from database. When I retrieve entry from a table, the page look like this. The header and form below table is repeated. I need help, thanks.
Here's the whole code I'm using:
<?php
session_start();
include('connection.php');
$username='username';
mysql_query("SELECT * FROM regmember WHERE username='$username'");
$query=("SELECT * FROM product");
$result=mysql_query($query);
while($row=mysql_fetch_array($result))
{
?>
<html>
<head>
<link rel="stylesheet" type="text/css" href="index.css">
<title>Music Light</title>
<div align="center"><h1>Music Light</h1></div>
<div id="menu">
<ul>
<li><?php echo 'Welcome, '.$_SESSION['username']; ?></li>
<li>Home</li>
<li>Product</li>
<li>Profile</li>
<li>Cart</li>
<li>Testimony</li>
<li>Transaction</li>
<li>Logout</li>
</ul>
</div>
<br>
<br>
<div align="center">
<table border="0">
<tr>
<td>ID</td>
<td></td>
<td><?php echo $row[0];?></td>
</tr>
<tr>
<td>Brand</td>
<td></td>
<td><?php echo $row[1];?></td>
</tr>
<tr>
<td>Instrument Type</td>
<td></td>
<td><?php echo $row[2];?></td>
</tr>
<tr>
<td>Price</td>
<td></td>
<td><?php echo $row[3];?></td>
</tr>
<tr>
<td>Stock</td>
<td></td>
<td><?php echo $row[4];?></td>
</tr>
<tr>
<td>Image</td>
<td></td>
<td><img height="150" width="150" src="productimg/<?php echo $row[6];?>"/></td>
</table>
</div>
<div align="center">
<table>
<form name="deleteentry" action="delete.php" method="get">
<tr>
<td>Delete which entry? (enter product id)</td>
<td><input type="text" name="delete"></td>
<td><input type="button" name="deletebutton" value="Delete"></td>
</tr>
</form>
</table>
</div>
<?php
}
?>
<br>
<br>
<div align="center"><p>Description template</p></div>
<footer>
<p align="center">Copyright © 2013 Music Light</p>
</footer>
missing </head> and <body> and </body>
i would suggest that the <html> <head></head> and <body> to be used outside the loop if u donot actually want to repeat. by loop i mean the while loop
You didn't closed your header with </head>
<head>
<link rel="stylesheet" type="text/css" href="index.css">
<title>Music Light</title>
</head> <= Include this
.
.
.
</html> <= Include this as well at the end
Related
I am making the modification for the query and already add and everything but in modifying it does not work with 'id' that I put after putting the address of the modification page
this is the table
<!DOCTYPE html>
<html>
<head>
<title> TABLA </title>
</head>
<body>
<center>
<table bgcolor="#85C1E9" border="3">
<thead>
<tr>
<th colspan="1">Nuevo</th>
<th colspan="5">Lista de usuarios</th>
</tr>
</thead>
<tbody>
<tr>
<td>Id</td>
<td>Nombre</td>
<td>Apellido</td>
<td>Correo</td>
<td colspan="2"><center>Operaciones</center></td>
</tr>
<?php
include("conexiones.php");
$query="SELECT * FROM usuarios";
$resultado=$conexion->query($query);
while ($row=$resultado->fetch_assoc()) {
?>
<tr>
<td><?php echo $row['id'];?></td>
<td><?php echo $row['nombre'];?></td>
<td><?php echo $row['apellido'];?></td>
<td><?php echo $row['correo'];?></td>
<td><a href="modificar.php?id=<?php echo $row['id'];
?>">Modificar</a></td>
<td><a href="eliminar.php?id=<?php echo $row['id']; ?
>">Eliminar</a></td>
</tr>
<?php
}
?>
</tbody>
</table>
</center>
</body>
</html>
here the modify page
<!DOCTYPE html>
<html>
<head>
<title>Guardar</title>
</head>
<body>
<center>
<form action="guardar.php" method="POST" name="guardar"><br><br><br>
<?php
$id=$_REQUEST['id'];
include("conexiones.php");
$query="SELECT * FROM usuarios";
$resultado=$conexion->query($query);
$row=$resultado->fetch_assoc();
?>
<input type="text" required="" name="nombre" placeholder="Nombre..."
value="<?php echo $row['nombre'];?>"><br><br>
<input type="text" required="" name="apellido"
placeholder="Apellido..." value="<?php echo $row['apellido'];?>">
<br><br>
<input type="text" required="" name="correo"
placeholder="Correo..." value="<?php echo $row['correo'];?>"><br>
<br>
<input type="submit" value="Aceptar">
</form>
</center>
</body>
</html>
the error is that when I press modify in the query I get like this:
http://localhost/modificar.php?id=%3C?echo%20$row[%27id%27];?%3E
and the way it should go (for example) is like this:
http://localhost/modificar.php?id=1
Try this:
<?php
include("conexiones.php");
$query="SELECT * FROM usuarios";
$resultado=$conexion->query($query);
?>
<?php while ($row=$resultado->fetch_assoc()): ?>
<tr>
<td><?= $row['id'] ?></td>
<td><?= $row['nombre'] ?></td>
<td><?= $row['apellido'] ?></td>
<td><?= $row['correo'] ?></td>
<td><a href="modificar.php?id=<?= $row['id'] ?>">
Modificar</a></td>
<td><a href="eliminar.php?id=<?= $row['id'] ?>">
Eliminar</a></td>
</tr>
<?php endwhile; ?>
hope it helps.
Hi i want to implement DataTable in the table to populate data from my db in my php page, the below code i used, but its not working, not getting the data table, instead i am getting the normal table only -
<head>
<link rel="stylesheet" type="text/css" href="../DataTables-1.10.7/media/css/jquery.dataTables.min.css">
<script src="../DataTables-1.10.7/media/js/jquery.dataTables.min.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="../DataTables-1.10.7/extensions/Responsive/css/dataTables.responsive.css">
<script src="../DataTables-1.10.7/extensions/Responsive/js/dataTables.responsive.js" type="text/javascript"></script>
</head>
<div id="example_wrapper" class="dataTables_wrapper" role="grid">
<div class="fg-toolbar ui-toolbar ui-widget-header ui-corner-tl ui-corner-tr ui-helper-clearfix">
<?php
$sql="select product_id,product_name,original_price,offer_price,product_rating,image_main,stock_in_hand from niad_products order by product_id desc";
$result=$linkID1->query($sql);
$c=#mysqli_num_rows($result);
if($c>=1){?>
<script>
$(document).ready(function() {
$('#example').DataTable( {
responsive: true
} );
} );
</script>
<div id="printable">
<table id="example" class="display" cellspacing="0" width="100%" style="color:#FFF">
<thead>
<tr>
<th>Image</th>
<th>Product Name</th>
<th>Original Price</th>
<th>Offer Price</th>
<th>Rating</th>
<th>Stock</th>
</tr>
</thead>
<tbody>
<?php while($row=mysqli_fetch_array($result)){?>
<tr>
<td>
<?php echo "<img width='100' height='100' src=../product-images/".$row['image_main'] ." />"; ?></td>
<td>
<?php echo $row['product_name']; ?>
</td>
<td>
<?php echo $row['original_price']; ?>
</td>
<td>
<?php echo $row['offer_price']; ?>
</td>
<td>
<?php echo $row['product_rating']; ?>
</td>
<td>
<?php echo $row['stock_in_hand']; ?>
</td>
</tr>
<?php
}
?>
</tbody>
</table>
</div>
<?php } else {echo "No records";} ?>
</div>
</div>
Can anyone guide me with my mistake. It will be very helpful. Thanks
I am having two php files, one contains a form and another to display the content entered and save button. After confirming the details are correct he has to save and the data should be inserted into the table. I have given the code below
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js">
</script>
<script src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.1.1.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"> </script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"> </script>
</head>
<body>
<?php
$roll=$_POST['roll'];
$sname=$_POST['sname'];
$fname=$_POST['fname'];
$gender=$_POST['gender'];
$aadhar=$_POST['aadhar'];
$caste=$_POST['caste'];
?>
<div class="container container-center">
<!-------------total panel------------------------------------>
<div class="panel-info">
<!------panel heading------>
<div class="panel-heading">
<h2><center><u>STUDENT DETAILS</u></center></h2>
</div> <!-panel heading->
<div class="panel-body">
<form method="post" action="">
<table align="center" border="0">
<tbody>
<tr>
<td rowspan="7"><?php echo"<img src=/photo/$roll.jpg width='200px' height='300px' id='photo'>"; ?></td>
<td>1. Roll Number & Photo:</td>
<td><?php echo"".strtoupper($roll).""; ?></td>
</tr>
<tr>
<td>2. Name of the Student:</td>
<td><?php echo"".strtoupper($sname).""; ?></td>
</tr>
<tr>
<td>3. Name of the Father:</td>
<td><?php echo"".strtoupper($fname).""; ?></td>
</tr>
<tr>
<td>4. Gender:</td>
<td><?php
if($gender=='M')
{ echo"Male";}
else
{echo"Female";}
?></td>
</tr>
<tr>
<td>5. Aadhar Number:</td>
<td><?php echo"$aadhar"; ?></td>
</tr>
<tr>
<td>6. Caste:</td>
<td><?php echo"$caste"; ?></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" id="submit" name="submit" class="btn btn-info" value="save"></td>
</tr>
</tbody>
</table>
</form>
</div>
</div>
</div>
<?php
if(isset($_POST['submit']))
{
echo"<script>alert('success')</script>";
}
?>
</body>
when i click the save button then only the data must be saved. but even if not click the save the php code in isset is executing.
the data obtained by $_POST is from the form.
Please help me.
NOTE:
Actually Problem is that, you don't get the data on this page.. in your POST request with given variable so that Please Just Check it . Other Code Is Fine. !! ( Here I am Just Pass Dummy Data ) Like Below.
$roll= '1234';
$sname='XYZ';
$fname= 'ABC';
$gender= 'M';
$aadhar= '123456789100';
$caste= 'A12345';
Solution: You Have To Get DATA Here in post request from your first_php_page form where user enter the details regarding given fields: roll,sname,fname,gender,aadhar,caste
After here in secound_php_page check that Submit button is set then store the values in varable Like below Code:
NOTE: At The End YoU Have To Write The Insert Query On Save Button Click. To Store The data in Database.
<?php
if(isset($_POST['Submit'])){
$roll=$_POST['roll'];
$sname=$_POST['sname'];
$fname=$_POST['fname'];
$gender=$_POST['gender'];
$aadhar=$_POST['aadhar'];
$caste=$_POST['caste'];
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js">
</script>
<script src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.1.1.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"> </script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"> </script>
</head>
<body>
<?php
/*
$roll=$_POST['roll'];
$sname=$_POST['sname'];
$fname=$_POST['fname'];
$gender=$_POST['gender'];
$aadhar=$_POST['aadhar'];
$caste=$_POST['caste'];
*/
// SET THE DUMMY DATA FOR Result check
$roll= '1234';
$sname='XYZ';
$fname= 'ABC';
$gender= 'M';
$aadhar= '123456789100';
$caste= 'A12345';
?>
<div class="container container-center">
<!-- total panel -->
<div class="panel-info">
<!-- panel heading -->
<div class="panel-heading">
<h2><center><u>STUDENT DETAILS</u></center></h2>
</div>
<!--panel heading -->
<div class="panel-body">
<form method="post" action="">
<table align="center" border="0">
<tbody>
<tr>
<td rowspan="7"><?php echo"<img src=/photo/$roll.jpg width='200px' height='300px' id='photo'>"; ?></td>
<td>1. Roll Number & Photo:</td>
<td><?php echo"".strtoupper($roll).""; ?></td>
</tr>
<tr>
<td>2. Name of the Student:</td>
<td><?php echo"".strtoupper($sname).""; ?></td>
</tr>
<tr>
<td>3. Name of the Father:</td>
<td><?php echo"".strtoupper($fname).""; ?></td>
</tr>
<tr>
<td>4. Gender:</td>
<td><?php
if($gender=='M')
{ echo"Male";}
else
{echo"Female";}
?></td>
</tr>
<tr>
<td>5. Aadhar Number:</td>
<td><?php echo"$aadhar"; ?></td>
</tr>
<tr>
<td>6. Caste:</td>
<td><?php echo"$caste"; ?></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" id="submit" name="submit" class="btn btn-info" value="save"></td>
</tr>
</tbody>
</table>
</form>
</div>
</div>
</div>
<?php
if(isset($_POST['submit']))
{
echo"<script>alert('success')</script>";
}
?>
</body>
</HTML>
OUTPUT: DATA Display
AND ONCLICK SAVE
There are few issues with your code, such as:
There's no point having a form and save button(in another page) if you don't have input elements and don't send your data using $_POST superglobal. Create input elements for each of your fields with type="hidden", for example like this:
<td><?php echo strtoupper($roll); ?><input type="hidden" name="roll" value="<?php echo strtoupper($roll); ?>"></td>
Here's the full form code,
// your code
<form method="post" action="">
<table align="center" border="0">
<tbody>
<tr>
<td rowspan="7"><?php echo"<img src=/photo/$roll.jpg width='200px' height='300px' id='photo'>"; ?></td>
<td>1. Roll Number & Photo:</td>
<td><?php echo strtoupper($roll); ?><input type="hidden" name="roll" value="<?php echo strtoupper($roll); ?>"></td>
</tr>
<tr>
<td>2. Name of the Student:</td>
<td><?php echo strtoupper($sname); ?><input type="hidden" name="sname" value="<?php echo strtoupper($sname); ?>"></td>
</tr>
<tr>
<td>3. Name of the Father:</td>
<td><?php echo strtoupper($fname); ?><input type="hidden" name="fname" value="<?php echo strtoupper($fname); ?>"></td>
</tr>
<tr>
<td>4. Gender:</td>
<td>
<?php
if($gender=='M'){
echo"Male";
}else{
echo"Female";
}
?>
<input type="hidden" name="gender" value="<?php echo $gender; ?>">
</td>
</tr>
<tr>
<td>5. Aadhar Number:</td>
<td><?php echo $aadhar; ?><input type="hidden" name="aadhar" value="<?php echo $aadhar; ?>"></td>
</tr>
<tr>
<td>6. Caste:</td>
<td><?php echo $caste; ?><input type="hidden" name="caste" value="<?php echo $caste; ?>"></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" id="submit" name="submit" class="btn btn-info" value="save"></td>
</tr>
</tbody>
</table>
</form>
// your code
I don't see any code where you're inserting the form data into the table, you should have a code block like this in another page(where you have displayed the form data and has the save button):
if(isset($_POST['submit'])){
$roll = $_POST['roll'];
$sname = $_POST['sname'];
$fname = $_POST['fname'];
$gender = $_POST['gender'];
$aadhar = $_POST['aadhar'];
$caste = $_POST['caste'];
// your INSERT operation
}
This is very quick.
I have a form that when submitted should add user input into my DB. I have had a similar form working well but for some reason this one is not working.
Please excuse my sloppy code but here is the whole page. For some reason 'observation' will not take the user input and display it on the next page (showOne.php). The next page simply shows a blank space for observation and I checked the DB and there was nothing in the observation field of course.
Is it something simple that I can't see? I've been at this for days since it is identical to another form I have that works well on another page.
Thank you for any insight.
<?php
//including the database connection file
include("config.php");
$activePage = "start.php";
if(isset($_POST['update'])) {
$id = $_POST['id'];
$observation = $_POST['observation'];
$result = mysqli_query($mysqli, "UPDATE tasks SET observation='$observation' WHERE id=$id");
header("Location: showOne.php?id=$id");
}
//getting id from url
$id = $_GET['id'];
//selecting data associated with this particular id
$result2 = mysqli_query($mysqli, "SELECT * FROM users WHERE id=$id ORDER BY id ASC");
$result = mysqli_query($mysqli, "SELECT * FROM tasks ORDER BY taskNumber ASC");
include_once "nav.php";
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Pathfinder - A User Testing Dashboard</title>
<meta name="description" content="Pathfinder - A User Testing Dashboard">
<meta name="author" content="James Stables - Thurs April 13th 2017">
<link rel="stylesheet" href="core.css">
<link href="https://fonts.googleapis.com/css?family=Open+Sans:400,600,700" rel="stylesheet">
<!--[if lt IE 9]>
<script src="https://cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.js"> </script>
<![endif]-->
<script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
</head>
<body>
<header>
<h1 class="logo"><img src="images/logo.png">Pathfinder</h1>
<h4>User Testing Dashboard</h4>
</header>
<section class="nonav">
<div class="showAllUsers">
<table border='0'>
<tr>
<?php while($res = mysqli_fetch_array($result2))
{ ?>
<td class="widthHundred no-border left"><h2><?php echo $res['nameFirst']; ?></h2></td>
<?php } ?>
</tr>
</table>
<table border='0'>
<thead>
<tr>
<th>Image</th>
<th>Category</th>
<th>Task Number</th>
<th>Task Name</th>
<th>Observation</th>
<td> </td>
<td> </td>
<td> </td>
</tr>
</thead>
<tbody>
<form name="start" method="post" action="start.php" enctype="multipart/form-data">
<tr>
<td><a href="<?php echo $res['$image'];?>" data-lightbox="example-1" data-title="Task Number <?php echo $res['taskNumber'];?>">
<img id="imageResize" src="<?php echo $res['image'];?>" /></a></td>
<td><?php echo $res['category'];?></td>
<td><?php echo $res['taskNumber'];?></td>
<td><?php echo $res['taskName'];?></td>
<td><input type="text" name="observation" value="<?php echo $res['observation'];?>"></td>
<td> </td>
<td> </td>
<td> </td>
<?php } ?>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td><input type="hidden" name="id" value="<?php echo $_GET['id'];?>"><input type="submit" class="buttonUpdate right" name="update" value="Update"></td>
<td><a class="buttonCancel right" href="tasks.php" onClick="return confirm('Cancel and go back?')">Cancel</a></td>
</tr>
</form>
</tbody>
</table>
</div>
</section>
<script src="js/lightbox-plus-jquery.min.js"></script>
<script>
lightbox.option({
'resizeDuration': 200,
'showImageNumberLabel': false,
'fitImagesInViewport': true
})
</script>
</body>
</html>
I want to create a crf form for my university project .
i created course table i select some data from course but where student click the completed course and next click .then next page show same data base table but not those courses, student already selected.and
then student can subset for applied courses.
But when i select some course and click next, But it show the previous row in course table. but i want selected course row not select when i click . cause completed course not want to select for applying course.
I want to select some row from a database when aply it show the same databases all row except the selected row
i add the same line in the problem line..
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>
CRF Form
</title>
<link rel="stylesheet" href="CSS/admin_style.css" >
</head>
<body>
<div id="header">
<a href="index.php">
<h1>
Welcome to the CRF Form
</h1>
</a>
</div>
<form action="selection.php" method="POST" enctype="multipart/form-data" >
<div id="">
<table width="1000" border="5" align="center">
<tr>
<td colspan="8" align="center" bgcolor="yellow">
<h1>
Slect your completed course
</h1>
</td>
</tr>
<tr bgcolor="orange">
<th>
selection:
</th>
<th>
Course id:
</th>
<th>
Course title:
</th>
<th>
Course credits:
</th>
<th>
Course statust:
</th>
<th>
Delete Post:
</th>
<th>
Edit Post:
</th>
</tr>
<?php
include("includes/connect.php");
$query="select * from course";
$run=mysql_query($query);
while($row=mysql_fetch_array($run)){
$id=$row['id'];
$course_id=$row['course_id'];
$course_title=$row['course_title'];
$course_credits=$row['course_credits'];
$course_status=$row['course_status'];
?>
<tr align="center" bgcolor="pink">
<td>
<input type="checkbox" name="complete[]" value="<?php echo $id; ?>" />
</td>
<td>
<?php echo $course_id; ?>
</td>
<td>
<?php echo $course_title; ?>
</td>
<td>
<?php echo $course_credits; ?>
</td>
<td>
<?php echo $course_status; ?>
</td>
<td>
<a href="delete.php?del=<?php echo $post_id ?>">
Delete
</a>
</td>
<td>
<a href="Edit.php?edit=<?php echo $post_id ?>">
Edit
</a>
</td>
</tr>
<?php } ?>
<tr>
<td align="center" colspan="7">
<input type="submit" name="sub" value="NEXT">
</td>
</tr>
</table>
</form>
</div>
</body>
</html>
this is the selec.php
<html>
<head>
<title>
CRF Form
</title>
<link rel="stylesheet" href="CSS/admin_style.css" >
</head>
<body>
<div id="header">
<a href="index.php">
<h1>
Welcome to the CRF Form
</h1>
</a>
</div>
<div id="">
<table width="1000" border="5" align="center">
<tr>
<td colspan="8" align="center" bgcolor="yellow">
<h1>
Slect your completed course
</h1>
</td>
</tr>
<tr bgcolor="orange">
<th>selection:</th>
<th>Course id:</th>
<th>Course title:</th>
<th>Course credits:</th>
<th>Course statust:</th>
<th>Delete Post:</th>
<th>Edit Post:</th>
</tr>
<?php
include("includes/connect.php");
$check=$_POST['complete'];
foreach($check as $ch){
$select= " id!='".$ch."' and ";//here is the problem
}
$query="select * from course
where $select id!='0'";
$run=mysql_query($query);
while($row=mysql_fetch_array($run)){
$id=$row['id'];
$course_id=$row['course_id'];
$course_title=$row['course_title'];
$course_credits=$row['course_credits'];
$course_status=$row['course_status'];
?>
<tr align="center" bgcolor="pink">
<td>
<input type="checkbox" name="completed" /></input>
</td>
<td><?php echo $course_id; ?></td>
<td><?php echo $course_title; ?></td>
<td><?php echo $course_credits; ?></td>
<td><?php echo $course_status; ?></td>
<td>Delete</td>
<td>Edit</td>
</tr>
<?php } ?>
</table>
</div>
</body>
</html>
I think that you're saying the once the course is selected it shouldn't be displayed on the next page where the student can have a look on the other courses?
If is so then you can use following sql query on the next page where you don't want to display the student's completed course.
SELECT * FROM course WHERE id != $course_id
Let me know if I'm wrong. I didn't comment out as my reputations were low and stackoverflow didn't allow me to.
[EDITED]
This is your complete code.
Your select php file:
//assuming that you are logging in the students with their username or email id, if so then store their username in a session where logging in.
<?php
$user = $_SESSION['username'];
include("includes/connect.php");
if (isset($_POST['submit'])){
$course_id= $_POST['course_id'];
$course_title= $_POST['course_title'];
$course_credits= $_POST['course_credits'];
$course_status= $_POST['course_status'];
$query="SELECT course.id,course.title,course.credits,course.status FROM course WHERE course.username = $user";
$run=mysqli_query($conn,$query);
while($row=mysqli_fetch_array($run)){
$course_id= $_SESSION['course_id'] = $row['course_id'];
$course_title=$row['course_title'];
$course_credits=$row['course_credits'];
$course_status=$row['course_status'];
}
?>
Now in your next php file :
$already_selected_course = $_SESSION['course_id'];
Now the query should look like.
$query = "SELECT course.id,course.title,course.credits,course.status FROM course WHERE course.id != $already_selected_course";
This is it. Note: This solution might contain some errors of brackets etc but the logic is clear.
For better knowledge have a look at my MySQL Complete Video Series here!