
May 26th, 2003, 03:17 AM
|
|
Junior Member
|
|
Join Date: May 2003
Posts: 4
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
EEK! Errors in developing.
So I am building the school site for next year, and they want to show a list of all the courses they offer. All was going good until I started making redunt calls to MySQL - once to get course listing and again to put a Course Category next to "Courses Offered In " . . . and to complicate matters even more - when the while start looping it does not grab the first entry (ie anything that should go alphabetically first.
Anyone out there - please HELP!
This page appears after URL is clicked on "courselisting.php?courseId=1
PHP Code:
<?php
$db_server = "localhost";
$db_db = "database";
$db_user = "databaseuser";
$db_pass = "databasepassword";
$courseId = $HTTP_GET_VARS["courseId"];
@$sConn = mysql_connect($db_server, $db_user, $db_pass);
@$dConn = mysql_select_db($db_db, $sConn);
$cResult = mysql_query("select * from bhs_courses where courseId = '$courseId'");
$cRow = mysql_fetch_array($cResult);
$nResult = mysql_query("select * from bhs_classes where courseId = '$courseId' order by courseName asc");
$nRow = mysql_fetch_array($nResult);
?>
<html>
<head>
<title> Your High School || <?php echo str_replace("\"", "\\\"", $cRow["course"]); ?></title>
</head>
<body>
<table width='500' cellspacing='0' cellpadding='0'>
<tr><td colspan="5">
<font face="arial" size="4"><b>Courses Offered In <?php echo str_replace("\"", "\\\"", $cRow["course"]); ?></b></font>
</td></tr>
<tr><td colspan="5" valign="middle" align="center" height="40px">
<hr>
</td></tr>
<?
if($nRow) {
while($nRow = mysql_fetch_array($nResult))
{
?>
<tr>
<td>
<b>
<?php echo str_replace("\"", "\\\"", $nRow["courseName"]); ?>
</b>
</td>
<td>
<?php echo str_replace("\"", "\\\"", $nRow["classGrade"]); ?>
</td>
<td>
<?php echo str_replace("\"", "\\\"", $nRow["courseNum"]); ?>
</td>
<td>
<?php echo str_replace("\"", "\\\"", $nRow["credit"]); ?>
</td>
<td>
<?php echo str_replace("\"", "\\\"", $nRow["creditType"]); ?>
</td>
</tr>
<tr><td colspan="4"><?php echo str_replace("\"", "\\\"", $nRow["courseDes"]); ?>
<tr>
<td height="40px">
</td>
</tr>
<?php
}
?>
<tr><td colspan="5" valign="middle" align="center" height="40px">
<hr>
</td></tr>
<tr><td colspan="5" valign="middle" align="center" height="40px">
<a href='/registration/index.php'><font face='verdana' size='2' color='black'>Back To Course Listing</font></a>
</td></tr>
</table>
<?php
}
else {
?>
<tr><td colspan="5" valign="middle" align="center" height="40px">
Currently no courses!
</td></tr>
<tr><td colspan="5" valign="middle" align="center" height="40px">
<hr>
</td></tr>
<tr><td colspan="5" valign="middle" align="center" height="40px">
<a href='/registration/index.php'><font face='verdana' size='2' color='black'>Back To Course Listing</font></a>
</td></tr>
</table>
<?
}
?>
|