I'm trying to pass the variable from one page to another. However, when I try to get the variable using php it just passes it as a string to the other page.
'<a href="selected.php?varname=<?php echo $row[title]; ?>">' . $row['title'] . '</a>'
This is a cell in a table and is a link that when clicked should go the other page with the title. However, instead I get this.
array (size=1) 'varname' => string '' (length=26)
<?php
$mysqli = mysqli_connect('localhost','scott','tiger','courses');
if(mysqli_connect_errno($mysqli)) {
echo 'Failed to connect to MySQL: ' . mysqli_connect_error();
}
class Courses
{
public $title;
public $id;
public $award;
}
$res = mysqli_query($mysqli, "SELECT title,id,award FROM course LIMIT 10");
echo "<table align='center' style='margin: 0px auto;'>";
while($row = $res->fetch_assoc()) {
$courses = new Courses;
$courses->title = $row['title'];
$courses->id = $row['id'];
$courses->award = $row['award'];
$varname = $row['title'];
echo "<tr><td style='padding-right:25px'>" . '<a href="selected.php?varname=<?php echo $row[title]; ?>">' . $row['title'] . '</a>' . "</td><td style='padding-right:25px'>" . $row['id'] . "</td><td style='padding-right:25px'>" . $row['award'] . "</td></tr>";
}
?>
That is the rest of the php code.
<?php
$var_value = $_GET['varname'];
echo serialize($var_value);
var_dump($_GET);
exit;
This is where I try to get it in the other page