I have code that I am trying to update and improve.
The original developer used the db/db.php abstraction layers, however the last guy to mess with this code did not. He created another mysql_connect.php and placed them where he needed them which has caused me utter confusion.
The original developer used $db->sql_query($sql) which I am most familar with.
The last guy used stuff like
Code:
$res = @mysql_query($query);
or
Code:
$media = mysql_result($res, 0, "media_dir");
I have been trying to understand what mysql_result($res, 0, "media_dir") would do and what the equivalent would be.
Here is what the last guy did.
Code:
require_once('mysql_connect.php');
//include($somCBT_root_path . 'includes/page_header.'.$phpEx);
$query = "SELECT media_dir FROM course WHERE course_id = " .$cid." LIMIT 1";
$res = @mysql_query($query);
$media = mysql_result($res, 0, "media_dir");
$media = addslashes($media);
//Here, we are joining the quiz, quiz_questions, and questions tables in order to have a single recordset with all of the information that we will need to
//post on the print page. This is required in order to ensure that we are only dealing with a single test for a single course - SMQ
if($lock=='y') {
$query1 = "SELECT * FROM quiz, quiz_questions WHERE quiz.quiz_id=".$qid." AND quiz.course_id=".$cid." AND quiz.quiz_id=quiz_questions.quiz_id AND quiz.course_id=quiz_questions.course_id ORDER BY quiz_questions.ques_order" ;
}else{
$query1 = "SELECT quiz.quiz_name, quiz.year_used, quiz_questions.ques_order, quiz_questions.ques_id, questions.* FROM quiz, quiz_questions, questions WHERE quiz.quiz_id=".$qid." AND quiz.course_id=".$cid." AND quiz.quiz_id=quiz_questions.quiz_id AND quiz_questions.ques_id=questions.question_id ORDER BY quiz_questions.ques_order" ;
}
$result=mysql_query($query1);
//Count the number of records returned from the SQL query, and use this to tell the loop when to stop iterating through the associative array created from the
//database query - SMQ
$num=mysql_num_rows($result);
mysql_close();
//print_r($result);
$med = $root_path.$media;
//}else{
// break();
//}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Print Test</title>
</head>
View next topic View previous topic
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum