Jump to content

acuken

New Members
  • Posts

    9
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

acuken's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thanks, I have been googling and I have tried a foreach statement and a do while statement. I hope I don't need to create a temporary table.
  2. I'm trying to update records in a Db. I have a record called "classOffering" and I have associated records for that offering called "classSessions". You have 1 classOffering for 1 to 6 classSessions. The process I use has the user create the classOffering and say how many classSession there will be then I create how ever many sessions they say. I then display the classSessions so they can be edited and updated in the Db. I can't seem to update and set more than one record even though there are more. I know I need to use a while or foreach statement, but I can't seem to do it. Here's my code so far: [pre] $sessSet = "UPDATE classSessions SET startDate= '$startDate', startTime= '$startTime', time= '$time' WHERE classSessions.sessionId = $sessionId "; [/pre] Thanks for any help.
  3. Thanks for everything, much respect to you.
  4. whoops. Just trying to make it read easier and erased beginning of table. So each record is it's own table because that's how I could make it go. Corrected code: $sql = "SELECT * FROM classOfferings, classes, instructors WHERE classes.classId = classOfferings.classId AND classOfferings.instructorId = instructors.instructorId AND classOfferings.startDate >= CURDATE() ORDER BY classOfferings.startDate"; if(! $retval ) { die('Could not get schedule: ' . mysql_error()); } while($row = mysql_fetch_array($retval, MYSQL_ASSOC)) { echo "<table id='schedule'><tr><td>{$row['dates']}"; if ($row['hours'] != 0){ echo "</td> "; } else { echo "CANCELLED</td>"; } echo "<td class='cell2'>". "<a href='classDetail.php?seq={$row['seq']}'>{$row['title']}</a>". "{$row['days']}". "{$row['times']}". "<a href='instructorDetail.php?instructorId={$row['instructorId']}'>{$row['fName']} "." ". "{$row['lName']}</a></td>} echo "</td></tr></table></div>"; }
  5. I've got a class schedule that spans two years and I would like to have the years as headers. startDate is unix date field. Here is existing code: $sql = "SELECT * FROM classOfferings, classes, instructors WHERE classes.classId = classOfferings.classId AND classOfferings.instructorId = instructors.instructorId AND classOfferings.startDate >= CURDATE() ORDER BY classOfferings.startDate"; if(! $retval ) { die('Could not get schedule: ' . mysql_error()); } while($row = mysql_fetch_array($retval, MYSQL_ASSOC)) { echo "{$row['dates']}"; if ($row['hours'] != 0){ echo "</td> "; } else { echo "CANCELLED</td>"; } echo "<td class='cell2'>". "<a href='classDetail.php?seq={$row['seq']}'>{$row['title']}</a>". "{$row['days']}". "{$row['times']}". "<a href='instructorDetail.php?instructorId={$row['instructorId']}'>{$row['fName']} "." ". "{$row['lName']}</a></td>} echo "</td></tr></table></div>"; }
  6. On further study inner join was the thing I needed. So the following code finds only instructors who are teaching classes (from classOfferings table) and puts one instance into the drop down menu. For each option instructorId is the value and fName and lName (from instructors table) are the clickable choices. Thanks for the help. <select size="1" name="instructor"> <option value="" selected>Search By Teacher...</option> <? $instrList=mysql_query("SELECT distinct classOfferings.instructorId, instructors.fName, instructors.lName FROM classOfferings INNER JOIN instructors WHERE instructors.instructorId = classOfferings.instructorId ORDER BY lName asc"); //$instrNameList=mysql_query("select fName, lName from instructors where classOfferings.instructorId = instructors.instructorId order by lName asc"); // Show records by while loop. while($instructor_list=mysql_fetch_assoc($instrList)){ $instrNames = ($instr_Name['fName']) . ($instr_Name['lName']); ?> <option value="<? echo $instructor_list['instructorId']; ?>" <? if($instructor_list['instructorId']==$select){ echo "selected"; } ?>> <? echo $instructor_list['fName'];?> <? echo $instructor_list['lName'];?> </option> <? // End while loop. } ?> </select>
  7. I put in some debbuging thing: ini_set('display_errors', 'On'); error_reporting(E_ALL | E_STRICT); no bugs on our issue, but other stuff on the page has issues... I think it's not finding anything. Just to back up - the following code gives me the instructors I want, but it gives me the instructorId not the fName and lName. So that is the general query working. <? $instrList=mysql_query("select distinct instructorId from classOfferings order by instructorId asc"); // Show records by while loop. while($instructor_list=mysql_fetch_assoc($instrList)){ ?> <option value="<? echo $instructor_list['instructorId']; ?>" <? if($instructor_list['instructorId']==$select){ echo "selected"; } ?>> <? echo $instructor_list['instructorId']; ?></option> <? // End while loop. } ?>
  8. Thanks for the link. I had tried joining before, but I'm not getting which one would be right. I recoded the query, but now the drop down has nothing in it. More info: There are 200 classes and 25 instructors, 15 of those instructors teach various numbers of the 200 classes. Here's the replacement code: $instrList=mysql_query("select distinct classOfferings.instructorId, instructors.fName, instructors.lName from instructorId AS co INNER JOIN instructors AS i ON instructorId WHERE co.instructorId = i.instructorId order by lName asc");
  9. I've got two tables (classOfferings, instructors). The fields I'm dealing with are 'co.instructorId', 'i.instructorId', 'i.fName', 'i.lName'. I have a form with dynamically generated drop downs. What I would like to do is check classOfferings table to see which instructors are teaching classes then display them in drop down with the 'instructorId' as the value and 'fName' and 'lName' as the user selectable part. So I have found the distinct 'instructorId', but I can't make 'fName' and 'lName' appear as the user selectable part. The code below produces a drop down which has invisible values, but still posts a value. <select size="1" name="instructor"> <option value="" selected>Search By Teacher...</option> <? $instrList=mysql_query("select distinct instructorId from classOfferings order by instructorId asc"); $instrNameList=mysql_query("select fName, lName from instructors where classOfferings.instructorId = instructors.instructorId order by lName asc"); // Show records by while loop. while($instructor_list=mysql_fetch_assoc($instrList)){ $instrNames = ($instr_Name['fName']) . ($instr_Name['lName']); ?> <option value="<? echo $instructor_list['instructorId']; ?>" <? if($instructor_list['instructorId']==$select){ echo "selected"; } ?>> <? echo $instrNames; ?></option> <? // End while loop. } ?> </select>
×
×
  • 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.