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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.