OK so far I have the following on a page called elearningcourse.php
<?php
$user = "root";
$host = "localhost";
$password = "";
$connection = mysql_connect($host, $root, $password) or die ("Couldn't connect to server.");
$database = "courses";
$db = mysql_select_db($database) or die ("Couldn't select database.");
$sql = "SELECT coursename FROM trainingtopics";
echo $sql."<br>";
$result = mysql_query($sql) or die(mysql_error());
echo $result."=result<br>";
while($row=mysql_fetch_array($result))
{ // NOTE this one ABOVE the echo
//echo "result found!";
//echo $row[0];
echo "<a href=\"details.php?id=".$row[0]."\">".$row[0]."</a><br>";
}
This is then linked as you can see to details.php with the following code:
<?php
if (isset($_GET['course'])) {
$user = "root";
$host = "localhost";
$password = "";
$connection = mysql_connect($host, $root, $password) or die ("Couldn't connect to server.");
$database = "courses";
$db = mysql_select_db($database) or die ("Couldn't select database.");
$course = mysql_real_escape_string($_GET['course']);
$res = mysql_query("SELECT * FROM id WHERE coursename = '$course'");
if ($res && mysql_num_rows($res) != 0) {
// get results from query
// output to browser with echo
} else {
//course name not found
//note: the query may have failed to so maybe check for that.
}
} else {
//no course specified
}
?>
But when you click a coursename in elearningcourses.php no results show at all