I have a problem which I am having difficulty with. I have a system which displays video tutorials. My code below displays the name of the video (eNISATQuestion) and the link to the video (eNISATVideo) as one href.
I want to add another column to display to link to a rating page with a similar layout as the section below.
<tr>
<td>
<a href='{$row['eNISATVideo']}'>{$row['eNISATQuestion']}</a>
</td>
</tr>
With values (eNISATRateRef) and (eNISATRating).
Thanks in advance
<?php
session_start();
include_once 'dbconnect.php';
if (!isset($_SESSION['user'])) header("Location: index.php");
$res = mysql_query("SELECT * FROM users WHERE user_id=".$_SESSION['user']);
$userRow = mysql_fetch_array( $res );
$userID = $_SESSION['user'];
$query = "SELECT eNISATQuestion, eNISATVideo, eNISATRateRef, eNISATRating FROM enisatquestion INNER JOIN enisatanswer WHERE
enisatanswer.eNISATID = enisatquestion.eNISATID AND user_id =
$userID AND eNISAT_watch = 1";
$result = mysql_query($query);
/* A default message if the query fails or there are no records */
$enisatquestion='<h2>Sorry, there are no records</h2>';
if($result) {/* if there is a recordset, proceed and generate html table */
$enisatquestion = "<table >";
while ($row = mysql_fetch_assoc($result)) {
**$enisatquestion .= "<tr><td><a href='{$row['eNISATVideo']}'>{$row['eNISATQuestion']}</a></td></tr>";**
}
$enisatquestion .= "</table>";
}
?>
<!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>Welcome - <?php echo $userRow['username']; ?></title>
<link rel="stylesheet" href="style.css" type="text/css" />
</head>
<body>
<div id="header">
<div id="left">
<label>NHSCT eNISAT Tutorials</label>
</div>
<div id="right">
<div id="content">
Welcome <?php echo $userRow['forename']; ?> <a href="home.php?home">Return to Homepage</a> <a
href="logout.php?logout">Sign Out</a>
</div>
</div>
<br>
<br>
<br>
<br>
<p align="center"><img src="title.jpeg" width="400"height="100" alt="title.jpeg">
<br>
<br>
<center>
<h2>Click on the each link to open your tutorial in Windows Media Player<h2>
<br>
<?php
/* output the html table here, below your header */
echo $enisatquestion;
/* If the query failed then the default gets displayed */
?>
</div>
</body>
</html>
Just add another td
element and add the new data you fetch from the database.
**$enisatquestion .= "
<tr>
<td><a href='{$row['eNISATVideo']}'>{$row['eNISATQuestion']}</a></td>
<td><a href='{$row['eNISATRateRef']}'>{$row['eNISATRating']}</a></td>
</tr>";**