I'm a total amateur with php. I've tried dozens of different things, mostly found while browsing around here. I've been at it for hours, and I'm starting to lose my mind. Lacking real knowledge I'm just guessing at this point.
I'm positive this code is completely butchered and will be highly offensive to many of you.
The goal is to display the mssql query results into a nice HTML table. So far, nothing is displaying except the table headers. The query should return dozens of rows.
Here's the current code, any suggestions?
<?php
// Open db connection
$dbc = mssql_connect('host', 'sa', 'password');
if (!$dbc || !mssql_select_db('dbname', $dbc)) {die('Unable to connect or select database!');}
// Select queries
$query = mssql_query("SELECT [name],[customer],[start_time],[end_time],[status] FROM dbo.reservation ORDER BY last_update DESC");
// display the results!
if (!mssql_num_rows($query)) {
echo 'No records found';
} else {
?>
<table>
<thead>
<tr>
<th>Name</th>
<th>Customer</th>
<th>Start Time</th>
<th>End Time</th>
<th>Status</th>
</tr>
</thead>
<tbody>
<?php
while ($row = mssql_fetch_row($query)) {
echo'<tr>';
echo'<td>'. $row['name']."</td>";
echo'<td>'. $row['customer'].'</td>';
echo'<td>'. $row['start_time'].'</td>';
echo'<td>'. $row['end_time'].'</td>';
echo'<td>'. $row['status'].'</td>';
echo'<tr>';
}
?>
</tbody>
</table>
<?php
}
?>
Note: This is for an internal site and I need to use mssql_connect.
var_dump($query)to see just what you are getting back.mssql_fetch_row()when what you really want ismssql_fetch_array()