i am currently having a hard time solving this stuff. This is the scenario....
The student must select a curriculum year (ex. 2007-2008) on a dynamic dropdown list for him to view the subjects on that curriculum. This curriculum are tables on the database. The dropdown is automatically updating everytime the admin added a new curriculum. The value of the dropdown list must be encoded with strtolower(), strip_tags(), and str_replace() because the curricula added by the admin are also encoded with these functions.
code to generate the curriculum year dropdown list:
Code: Select all
<form id="formStatus" name="currentStatus" method="post" action="includes/validateStatus.php">
<select name="selectedCurriculumIs" id="select">
[color=#BF0000]<?php[/color]
[color=#0000FF]include_once[/color] 'admin_/conn.php';
[color=#400000] $retrieveCurrs[/color] = [color=#008000]"SELECT * FROM curr_names"[/color];
[color=#400000]$retrieveNow[/color] = mysql_query([color=#400000]$retrieveCurrs[/color]);
[color=#0000FF]while[/color]($resultCurr = mysql_fetch_array([color=#400000]$retrieveNow[/color])){
echo "<option value='[color=#400000]$resultCurr[/color][id]'> [color=#400000]$resultCurr[/color][curryear] </option>";
}
[color=#BF0000]?>[/color]
</select>
<input type="hidden" name="isSubmittingStatus" value="yes">
<input type="submit" class="submitAssess" value="Submit Status"/>
</p>
</form>
validateStatus.php
Code: Select all
if (![color=#0000FF]isset[/color]([color=#400000]$_SESSION[/color])) {
session_start();
}
if ([color=#400000]$_REQUEST[/color][[color=#408000]'isSubmittingStatus'[/color]] == [color=#008000]"yes"[/color]) {
if([color=#400000]$_GET[/color][[color=#008000]'id'[/color]]){
[color=#0000FF]include_once[/color] '../admin_/conn.php';
[color=#400000]$id[/color] = (int) $_GET['id'];
[color=#400000]$getCurr[/color] = [color=#0000FF]mysql_query[/color]("SELECT currname FROM curr_names WHERE curryear = '$id'");
[color=#400000]$_SESSION[/color][[color=#008000]'selectedCurr'[/color]] = strtolower(strip_tags(str_replace(' ', '', [color=#400000]$getCurr[/color])));
}
}
This is the view page
Code: Select all
if (![color=#0000FF]isset[/color]([color=#400000]$_SESSION[/color])) {
session_start();
}
include_once '../../admin_/conn.php';
$retrieveFirstSem = "SELECT * FROM ".$_SESSION['selectedCurr']." WHERE subj_sem = '1' AND subj_level = '1'";
$returnFS = mysql_query($retrieveFirstSem);
while($fs = mysql_fetch_array($returnFS)){
echo "$fs[subj_code]";
echo "$fs[subj_desc]";
echo "$fs[lec_hrs]";
echo "$fs[lab_hrs]";
echo "$fs[subj_units]";
echo "$fs[subj_preq]";
}
Code: Select all
resourceid#4
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\xamppserv\htdocs\subjass\fresh\comsci\index.php on [color=#FF0000]line 59[/color]Code: Select all
$retrieveFirstSem = "SELECT * FROM ".$_SESSION['selectedCurr']." WHERE subj_sem = '1' AND subj_level = '1'";
Anyone please help, i really need a hand...Thank you so much in advance and God bless us