I am taking the plunge into PHP and Mysql and have run into a wall on how to edit my database table after displaying my output. I am looking to add a column to my table that will provide a edit hyperlink that will bring me to another page with the record so I can update it.
Below is my code so far.
<?php
//Open a new connection to the MySQL server
$mysqli = new mysqli('hostname','username','password','database');
//Output any connection error
if ($mysqli->connect_error) {
die('Error : ('. $mysqli->connect_errno .') '. $mysqli->connect_error);
}
//MySqli Select Query
$results = $mysqli->query("SELECT emp_num, name, supervisor FROM train2015 ORDER BY name desc");
print '<table border="1">';
while($row = $results->fetch_object()) {
print '<tr>';
print '<td>'.$row->emp_num.'</td>';
print '<td>'.$row->name.'</td>';
print '<td>'.$row->supervisor.'</td>';
print '</tr>';
}
print '</table>';
// close connection
$mysqli->close();
?>
Thanks in advance.
I have added the below to achieve what I was looking for to make the hyperlinks.
print '<td>';
print '<a href="edituser.php?=$row[emp_num]"">Edit</a>';
print '</td>';