Hi I'm new to PHP & MySQL and I am trying to write a journal page for an assignment, but I am not sure how to link a query to another page that shows the full query that has been clicked. Basically so the user can access their previous journal entries. below is the code I have written so far:
<?php
session_start();
if(isset($_SESSION['uname'])){
echo "Welcome " . $_SESSION['uname'];
}
require_once 'PHP/Constants.php';
$conn = new MySQLi(DB_SERVER, DB_USER, DB_PASSWORD,DB_NAME) or die ('There was a problem connecting to the database');
$uname = $_SESSION['uname'];
$query="SELECT Username, Date_Created, Title FROM journal";
$result=mysqli_query($conn, $query);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>My Journal</title>
</head>
<body>
<p>
<h1>My Journal</h1>
</p>
<?php
echo "<table width='400' border='1' cellspacing='0' cellpadding='3'>
<tr>
<th>Date</th>
<th>Title</th>
</tr>";
while ($rows=mysqli_fetch_array($result)){
if($rows['Username']=$uname) {
echo "<tr>";
echo "<td>" . $rows['Date_Created'] . "</td>";
echo "<td>" . $rows['Title'] . "</td>";
echo "</tr>";
} else echo "No Journal Entries Found";
}
echo "</table>";
?>
</table>
<form method="post" action="new_entry.php">
<p>
<input type="submit" id="new_entry" value="New Entry" name="new_entry" />
</p>
</form>
<form method="post" action="choices.php">
<p>
<input type="submit" id="back" value="Back" name="back" />
</p>
</form>
</body>
</html>
Thank you in advance for any help - Nick