With the following code in PHP, I want to echo the data fetched from some MySQL tables:
<html>
<head>
<meta http-equiv="Content-Language" content="en-gb">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Search Results</title>
</head>
<body bgcolor="#EFEFEF">
<table border="0" align=center width="95%" id="table1" bgcolor="#FFFFFF">
<tr>
<td>
<img border="0" src="index_files/text827854609.gif" width="260" height="67"></td>
</tr>
<tr>
<td><hr color="#C0C0C0" size="4"></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td>
<p align="left"><font face="Verdana" size="2">
Search Student Name For Results</font></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td>
<form method="POST" name="Informationform" action="searchresults.php">
<!--webbot bot="SaveResults" U-File="fpweb:///_private/form_results.csv" S-Format="TEXT/CSV" S-Label-Fields="TRUE" B-Reverse-Chronology="FALSE" S-Builtin-Fields -->
<p>
<b><font face="Verdana" size="2">Enter Name in Full</font></b> :
<input type="text" name="fullname" size="50">
<input type="submit" value="Search" name="senda"></p>
</form>
<?php
if(isset($_POST['senda'])){
include 'mysqlconn.php';
$con = mysqli_connect($host, $dbuser, $pass, $db) or die('Cannot Connect');
$name = mysql_escape_string($con,$_POST['fullname']);
$sql = "SELECT * FROM scores WHERE fullname = '$name'";
$result = mysqli_query($con,$sql) or die("Error: ".mysqli_error($con));
while($row = mysqli_fetch_array($result,MYSQLI_ASSOC))
{
echo $tablez;
}mysqli_free_result($result);
}
?>
</td>
</tr>
<tr>
<td>
$tablez = "<table border=0 width=99% id=table2>
<tr>
<td width=299 align=center><b>
<font face=Verdana size=2 color=#808080>Full Name</font></b></td>
<td width=171 align=center><b>
<font face=Verdana size=2 color=#808080>studentNo</font></b></td>
<td width=276 align=center><b>
<font face=Verdana size=2 color=#808080>SubjectName</font></b></td>
<td width=106 align=center><b>
<font face=Verdana size=2 color=#808080>GPA</font></b></td>
<td width=176 align=center><b>
<font face=Verdana size=2 color=#808080>CGPA</font></b></td>
<td align=center><b>
<font face=Verdana size=2 color=#808080>SCORE</font></b></td>
</tr>
<tr>
<td width=299 align=center> . $row['Fullname'] . </td>
<td width=171 align=center>. $row['studentNo']. </td>
<td width=276 align=center>. $row['SubjectName'].</td>
<td width=106 align=center> .$row['GPA']. </td>
<td width=176 align=center>.$row['CGPA']. </td>
<td align=center> .$row['SCORE'].</td>
</tr>
</br></table>";
</td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td><hr color="#808080" size="1">
<p>
<font face="arial" class="ws7" style="font-size: 9.3px; color: rgb(0, 0, 0); font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(212, 212, 212);">
EM Software Limited Nigeria<span class="Apple-converted-space"> </span></font><font class="ws7" style="font-size: 9.3px; color: rgb(0, 0, 0); font-family: arial; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(212, 212, 212)">©</font><font face="arial" class="ws7" style="font-size: 9.3px; color: rgb(0, 0, 0); font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(212, 212, 212);"><span class="Apple-converted-space"> </span>2016
All rights Reserved.</font></td>
</tr>
</table>
</body>
</html>
However, it doesn't work as I expect.
This is the output I'm getting:
How can I echo the data from the database?

$tablezshould be declared inside the loop, not after