Hi Guys. Thanks for your help.sofar The search box is now working, and displays the whole class but after selecting the record, it only shows the row to update. I can sort of live with that, but after updating a record, it returns no records and the Submit button has to be clicked again to display the class and updated records. Not cool.
The other issue I’m having is trying to get the query to order by name.
$result = $mysqli->query(“SELECT * FROM data WHERE classroom = '”.$classroom."’ ORDER BY ‘.name’;") or die($mysqli->error);
<?php require_once 'process.php'; ?> <?php if (isset($_SESSION['message'])): ?> <div class="alert alert-<?=$_SESSION['msg_type']?>">
<?php
echo $_SESSION['message'];
unset($_SESSION['message']);
?>
</div>
<?php endif ?>
<?php
?>
Home of English Reports
=
body {
margin: 0;
font-family: Arial, Helvetica, sans-serif;
}
.topnav {
overflow: hidden;
background-color: #008080;
}
.topnav a {
float: left;
color: #f2f2f2;
text-align: center;
padding: 14px 16px;
text-decoration: none;
font-size: 17px;
}
.topnav a:hover {
background-color: #ddd;
color: black;
}
.topnav a.active {
background-color: #4CAF50;
color: white;
}
<input type="submit" value="Submit">
<div class="container" align-content-center>
<?php
$classroom = (isset($_GET['classroom']) ? $_GET['classroom'] : null);
$result = $mysqli->query("SELECT * FROM data WHERE classroom = '".$classroom."' ORDER BY '.name';") or die($mysqli->error);
?>
<!-- ************************************** End Connect DB **************************************************** -->
<div class="row justify-content-center">
<form action="process.php" method="POST">
<input type="hidden" name="id" value="<?php echo $id; ?>">
<div class="form-group">
<h1><label><?php echo $name?></label></h1>
</div>
<form action="process.php" method="POST">
<input type="hidden" name="id" value="<?php echo $id; ?>">
<div class="form-group">
<h3><label>PA Teacher's Comment</label></h3> <select name = "pacomment">
<?php
while($rows = $resultcomment-> fetch_assoc())
{
$EnglishComment = $rows['EnglishComment'];
echo "<option value='$EnglishComment'>$name.$EnglishComment</option>";
}
?></h2>
</select><br>
<p>
<div class="form-group">
<?php
if ($update == true):
?>
<button type="submit" class="btn btn-info" name="update">Update</button>
<?php else: ?>
<!-- <button type="submit" class="btn btn-primary" name="save">Save</button> -->
<?php endif; ?>
</div>
</form>
<!-- ************************************** Begin Setup Table Headers *************************** -->
<div class="row justify-content-center">
<table class="table" width = "20%" border = "5" cellpadding = "1";>
<thead>
<tr>
<th><center>Action</center></th>
<th><center>ID</center></th>
<th>Name and Comment</th>
</tr>
</thead>
<!-- ************************************** End Setup Classlist Table Headers ****************** -->
<!-- ****** Loop thru Every Record From $result Query Variable and get variables and echo each variable into the table rows ********** -->
<?php
while ($row = $result->fetch_assoc()): ?>
<tr>
<td>
<center><a href="index.php?edit=<?php echo $row['id']; ?>"
class="btn btn-info">Assess</a></center>
</td>
<!-- ************************************** Put data into Classlist table rows ************************* -->
<td><center><?php echo $row['studentid']; ?></center></td>
<td><?php echo $row['name']." ".$row['pacomment'] ?></td>
</tr>
<?php endwhile; ?>
</table> <!-- *************** End of Classlist Table **************************************** -->
</div>
</div>
</div>
</body>
____process.php
<?php session_start();$mysqli = new mysqli(“localhost”,“ray”,“password”,“reports”) or die(mysqli_error($mysqli));
$id = 0;
$update = false;
$name = ‘’;
$classroom = ‘’;
if (isset($_GET[‘edit’])){
$id = $_GET[‘edit’];
$update = true;
$result = $mysqli->query(“SELECT * FROM data WHERE id=$id”) or die($mysqli->error());
if(isset($result->num_rows) && $result->num_rows > 0) {
$row = $result->fetch_array();
$name = $row[‘name’];
$classroom = $row[‘classroom’];
$pacomment = $row[‘pacomment’];
}
}
if (isset($_POST[‘update’])){
$id = $_POST[‘id’];
$pacomment = $_POST[‘pacomment’];
$mysqli->query(“UPDATE data SET pacomment= ‘$pacomment’ WHERE id=$id”) or die($mysqli->error);
$_SESSION['message'] = "Record has been updated!";
$_SESSION['msg_type'] = "warning";
header('location: index.php');
}