This is my code
if ($result!==false) {
$html_table =<table align="center" border="1" cellspacing="0" cellpadding="10" width="1000" word-wrap="break-word" display="inline-block">
<tr><th>Bank</th><th>Projects</th><th>Status</th><th>PS Lead</th><th>Support</th><th>Remarks</th></tr>';
foreach($result as $row){
$html_table .= '<tr><td>' .$row["bankname"]. '</td><td>' .$row["bpiproject"]. '</td><td>' .$row["bpistatus"]. '</td><td>' . $row["bpips"] . '</td><td>' . $row["bpisupport"] . '</td><td>' . $row["bpiremarks"] . '</td></tr>';
}
}
$conn = null;
$html_table .= '</table>';
echo $html_table;
and the error message says
Undefined variable: html_table in line 33
which is
$html_table .='</table>';
first you are starting your table inside an if
, which means if your condition is not met then the code inside if
will not run.
another is you are starting your variable string without '
after $html_table
Do this
$html_table = "";
if ($result!==false) {
$html_table ='<table align="center" border="1" cellspacing="0" cellpadding="10" width="1000" word-wrap="break-word" display="inline-block">
<tr><th>Bank</th><th>Projects</th><th>Status</th><th>PS Lead</th><th>Support</th><th>Remarks</th></tr>';
foreach($result as $row){
$html_table .= '<tr><td>' .$row["bankname"]. '</td><td>' .$row["bpiproject"]. '</td><td>' .$row["bpistatus"]. '</td><td>' . $row["bpips"] . '</td><td>' . $row["bpisupport"] . '</td><td>' . $row["bpiremarks"] . '</td></tr>';
}
$html_table .= '</table>';
}
$conn = null;
echo $html_table;
basically i have added $html_table = "";
before if
condition and $html_table .= '</table>';
inside if condition. When your if
condition is not met it will print blank $html_table