Código PHP:
require'includes\connection.php';
/*check if exist a $_SESSION[user_name] and the $_SESSION[user_type] =='admin' or
* $_SESSION[user_type] == 'faculty'. if exist create a $_SESSION[id]
* to identify who is working on and load all the stuff that have his id else send it back to index.php.*/
$id = $_SESSION['user_id'];
//select class from database
$myq = "select * from class where user_id =".$id;
$rmyq = mysqli_query($dbc,$myq);
while($f = mysqli_fetch_array($rmyq,MYSQLI_ASSOC)){
$class_id = $f['class_id'];
$classname = $f['classname'];
}
echo $class_id."<br>";
echo "<h1>$classname</h1>";
//select and show all the questions for that class_id
$qq = 'SELECT * FROM questions WHERE class_id ='.$class_id.'ORDER BY chapter_id ASC';
$rqq = mysqli_query($dbc,$myq);
echo "<form action=\"\" name=\"\" id=\"\" method=\"\">";
while($row = mysqli_fetch_array($rqq, MYSQLI_ASSOC)){
echo $row['idq']." ".$row['question']."<input type=\"checkbox\" name=\"active\" value=\"1\">";
}
echo "</form>";
Apache/2.4.7 (Win32) OpenSSL/1.0.1e PHP/5.5.9 Server at localhost Port 80
[SERVER_SOFTWARE] => Apache/2.4.7 (Win32) OpenSSL/1.0.1e PHP/5.5.9 [SERVER_NAME] => localhost [SERVER_ADDR] => ::1 [SERVER_PORT] => 80 [REMOTE_ADDR] => ::1 [DOCUMENT_ROOT] => C:/xamp2/htdocs [REQUEST_SCHEME] => http [CONTEXT_PREFIX] => [CONTEXT_DOCUMENT_ROOT] => C:/xamp2/htdocs [SERVER_ADMIN] => postmaster@localhost [SCRIPT_FILENAME] => C:/xamp2/htdocs/PHP-OOP/index.php [REMOTE_PORT] => 49622 [GATEWAY_INTERFACE] => CGI/1.1 [SERVER_PROTOCOL] => HTTP/1.1 [REQUEST_METHOD] => GET [QUERY_STRING] => p=setit [REQUEST_URI] => /php-oop/index.php?p=setit [SCRIPT_NAME] => /php-oop/index.php [PHP_SELF] => /php-oop/index.php [REQUEST_TIME_FLOAT] => 1406656743.408 [REQUEST_TIME] => 1406656743 ) [contact_email] => [email protected] [host] => local [local] => 1 [debug] => 1 [p] => setit [page] => settest.inc.php [page_title] => Set a New Exam [_SESSION] => Array ( [usertype] => faculty [user_id] => 2 [username] => Mario Miranda ) [dbc] => mysqli Object ( [affected_rows] => 1 [client_info] => mysqlnd 5.0.11-dev - 20120503 - $Id: bf9ad53b11c9a57efdb1057292d73b928b8c5c77 $ [client_version] => 50011 [connect_errno] => 0 [connect_error] => [errno] => 0 [error] => [error_list] => Array ( ) [field_count] => 4 [host_info] => localhost via TCP/IP [info] => [insert_id] => 0 [server_info] => 5.6.16 [server_version] => 50616 [stat] => Uptime: 21794 Threads: 1 Questions: 1165 Slow queries: 0 Opens: 606 Flush tables: 1 Open tables: 78 Queries per second avg: 0.053 [sqlstate] => 00000 [protocol_version] => 10 [thread_id] => 180 [warning_count] => 0 ) [id] => 2 [myq] => select * from class where user_id =2 [rmyq] => mysqli_result Object ( [current_field] => 0 [field_count] => 4 [lengths] => [num_rows] => 1 [type] => 0 ) [f] => [class_id] => 1 [classname] => 406 Object Oriented Programming - Java I [qq] => SELECT * FROM questions WHERE class_id =1ORDER BY chapter_id ASC [rqq] => mysqli_result Object ( [current_field] => 0 [field_count] => 4 [lengths] => Array ( [0] => 1 [1] => 40 [2] => 1 [3] => 10 ) [num_rows] => 1 [type] => 0 ) [row] => Array ( [class_id] => 1 [classname] => 406 Object Oriented Programming - Java I [user_id] => 2 [tdate] => 2014-07-29 ) )
espero me puedan ayudar con este asunto.
Saludos Manuel Garcia.