Could someone please tell me why I am getting an error with this code at line 40... This has been kicking by beginner butt all over town and I'm gettin sick of it!
Line 40 is the one containing:
Here's the actual code...
Thanks for the help everyone, I really appreciate it!
--Isn't it nice of me to assume you will help ;0)
Line 40 is the one containing:
Code:
foreach ($data as $dat => $d) {
echo "<td>$d</td>";
}
Here's the actual code...
Code:
<?php
$host = 'dbServerName';
$user = 'myUser';
$pass = 'myPass';
$db = 'myDatabase';
$c = mssql_connect($host, $user, $pass) or die ('Could not connect to '.$host.' using '.$user.' credentials.');
mssql_select_db($db);
$query = "
SELECT * FROM myDatabase
";
$result = mssql_query($query);
$field_num = mssql_num_fields($result);
$row_num = mssql_num_rows($result);
$result_array = mssql_fetch_assoc($result);
echo "Using Database: $db<br>";
echo "Query: <em>$query</em><br>";
echo "Query Result: $result<br>Field Count: $field_num<br>Row Count: $row_num";
echo "<hr>\r\n\r\n";
$result_keys = array_keys($result_array);
$result_vals = array_values($result_array);
echo "<table border='1'><br>\r\n";
// creates table header row using column names
echo "<tr>\r\n";
foreach ($result_array as $key => $val) {
echo "<th>$key</th>\r\n";
}
echo "</tr>\r\n\r\n";
// end of th based row
//begin table cells holding row values
for ($row = 0; $row < $row_num; $row++){
$data = mssql_fetch_row($result);
echo "<tr>\r\n";
foreach ($data as $dat => $d) {
echo "<td>$d</td>";
}
echo "\r\n</tr>\r\n";
}
echo "\r\n\r\n</table>\r\n";
?>
Thanks for the help everyone, I really appreciate it!
--Isn't it nice of me to assume you will help ;0)