session_start();
require_once('../Connections/connection.php');
include_once('../include/header_functions.php');
show_header("Manage Quesion Pool");
echo "
Manage Question Pool
";
?>
Add a new question
// create the table to display questions
?>
|
Question Text |
Categories |
$sql = "SELECT * FROM tbl_q_categories";
$result = mysql_query($sql, $connection) or die("could not get categories" . mysql_error());
while ($row = mysql_fetch_array($result)){// for each category
//setting the current category id and category title
$q_category_id = $row['q_category_id'];
$q_category_title = $row['q_category_title'];
// display a row showing the category title
echo "";
echo " | ";//empty cell
echo "$q_category_id. $q_category_title | ";//print the category
echo " | ";//
echo "
";
// building the query
$query = "SELECT * FROM tbl_questions WHERE ";
for ($i=1; $i <= $q_category_id; $i++){
if ($i < $q_category_id){
$query .= ( "category_" . $i . " = 0 AND ");
}
else {
$query .= ( "category_" . $i . " = 1");
}
}//end of the for loop
//end of building the query
// now get all the questions that should be displayed under that category, using the query we built
$result2 = mysql_query($query, $connection) or die("could not query tbl_questions
" . mysql_error());
// print the question and the categories associated with it
while ($row2 = mysql_fetch_array($result2)){
$question_id = $row2['question_id'];
$question_text = $row2['question_text'];
$cat_1 = $row2['category_1'];
$cat_2 = $row2['category_2'];
$cat_3 = $row2['category_3'];
$cat_4 = $row2['category_4'];
$cat_5 = $row2['category_5'];
$cat_6 = $row2['category_6'];
$cat_7 = $row2['category_7'];
$cats_to_display = "";
if ($cat_1){
$cats_to_display .= "1 ";
}
if ($cat_2){
$cats_to_display .= "2 ";
}
if ($cat_3){
$cats_to_display .= "3 ";
}
if ($cat_4){
$cats_to_display .= "4 ";
}
if ($cat_5){
$cats_to_display .= "5 ";
}
if ($cat_6){
$cats_to_display .= "6 ";
}
if ($cat_7){
$cats_to_display .= "7 ";
}
echo "| ";
// find out whether the question is in use, and display "in use" if so
if (! in_use($question_id)){
echo "delete";
}
else{
echo"in use";
}
echo " | ";
echo "$question_text | $cats_to_display | ";
echo "
";
}
// blank row between categories
echo "
|
|
|
";
}// end of the while loop going through each category
//end of table
echo "
";
?>
Return to Main Menu