Jump to content

HELP


phpmonster69

Recommended Posts

this line is always causing an error for me, can anyone tell whats wrong

 

 

$query = "SELECT * FROM Class";

$result = mssql_query($query)

or die("Couldn't change the data!");

echo "<table border="1"> <tr> <th>ClassNo</th> <th>Days</th> <th>TimePeriod</th> <th>StartDate</th> <th>EmployeeID</th> <th>RoomID</th> <th>CourseNo</th> </tr>";

while ( $record = mssql_fetch_array($result) ){

echo "<tr><td>" . $record["ClassNo"] . "</td><td>" . $record["Days"] . "</td><td>" . $record["TimePeriod"] . "</td><td>" . $record["StartDate"]."</td><td>" . $record["EmployeeID"] . "</td><td>" . $record["RoomID"] . "</td><td>" . $record["CourseNo"] . "</td></tr>";

}

echo "</table>";

 

?>

Link to comment
https://forums.phpfreaks.com/topic/234724-help/
Share on other sites

For god's sake, how is one going to manage that code of yours? Even you can't! There's no need to echo the whole table in one row!

 

<?php
$query = "SELECT * FROM Class";
$result = mssql_query($query) or die('Error: ' . mssql_get_last_message());
?>
<table border="1">
<tr>
     <th>ClassNo</th>
     <th>Days</th>
     <th>TimePeriod</th>
     <th>StartDate</th>
     <th>EmployeeID</th>
     <th>RoomID</th>
     <th>CourseNo</th>
</tr>
<?php while ($record = mssql_fetch_array)) { ?>
<tr>
     <td><?php echo $record["ClassNo"]; ?></td>
     <td><?php echo $record["Days"]; ?></td>
     <td><?php echo $record["TimePeriod"]; ?></td>
     <td><?php echo $record["StartDate"]; ?></td>
     <td><?php echo $record["EmployeeID"]; ?></td>
     <td><?php echo $record["RoomID"]; ?></td>
     <td><?php echo $record["CourseNo"]; ?></td>
</tr>
<?php } ?>

 

Isn't it way more readable like this? Notice that appart from formatting it, I added mssql_get_last_message() to your query. If the query fails, it should show what error are you getting.

Link to comment
https://forums.phpfreaks.com/topic/234724-help/#findComment-1206236
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.