Evening everyone,
I'm in need of a little bit of help.
I've got a bit of quite basic PHP coding which is fetching data from a table in a MS SQL database and have come unstuck.
I'm trying to get the data to display in a table and regardless of what I do it just won't do it, the data is slapped on the page in a scrambled mess with no table headings at all (as if the browser isn't registering the table code).
<?php
$databs ='C:\Program Files\Microsoft SQL Server\MSSQL14.SQLEXPRESS\MSSQL\DATA\MRT.mdf';
$dbConnect = odbc_connect("MRTServ","","")
or die("Error opening database .... use the browsers BACK button");
if ($dbConnect)
$dbQuery = "SELECT * FROM Callouts";
$dbResult = odbc_exec($dbConnect,$dbQuery);
while (odbc_fetch_row($dbResult)) {
$Description = odbc_result($dbResult,3); //third column
$outcomes = odbc_result($dbResult,5); //fifth column
//or could retreive data by specifying the column field names
//specified in query
//$Description = odbc_result($dbResult, "Description");
//$outcomes = odbc_result($dbResult, "outcomes");
echo "<br />";
echo "$Description, $outcomes";
}
$o = '<div id=ATtable>
<table-id-"table1">
<thead>
<tr>
<th>Description</th>
<th>Outcomes</th>
</tr>
</thead>
<tbody>';
while ( $record = odbc_fetch_array($dbResult) )
{
$o='<tr><td>'.[$Description].'</td><td>'.[$outcomes].'</td></tr>';
}
$o='</tbody>
</table>
</div>';
echo $o;
odbc_close($dbConnect);
?>
This is the PHP code I've come up with but for the life of me cannot see where I've made the mistake or missed something.
Please can someone give me a nudge in the right direction?
Thanks, Dan