PHP native word document code, which is used to produce the simple PHP code of the exam // contains the database connection file and header file
// Initialize the session
Session_start ();
// Contains the database connection file and header file
?>
Exam native
Include ('head. php ');
Require ('dbconnect. php ');
?>
$ Juge = 0;
For ($ I = 1; ($ I <100); $ I)
{
$ A = $ I;
If (isset ($ _ POST [$ a])
{
If ($ juge = 0)
$ SQL. = 'Id = '. $ _ POST [$ a];
Else
$ SQL. = 'or id ='. $ _ POST [$ a];
$ Juge = 1;
}
}
If ($ SQL! = '')
{
$ SQL = 'select * FROM test where'. $ SQL;
$ Result_array = array (); // returns an array.
$ I = 0; // array subscript
$ Query_result = @ mysql_query ($ SQL, $ conn );
While ($ row = @ mysql_fetch_object ($ query_result ))
{
$ I;
$ Cout. = $ I .'';
$ Cout. = 'title difficulty: '. $ row-> difficulty .'
';
$ Cout. = ''. $ row-> content .'
';
} // While
?>
Class word
{
Function start ()
{
Ob_start ();
Print'Xmlns: w = 'urn: schemas-microsoft-com: office: word'
Xmlns = '''> http://www.w3.org/TR/REC-html40'> ';
}
Function save ($ path)
{
Print'';
$ Data = ob_get_contents ();
Ob_end_clean ();
$ This-> wirtefile ($ path, $ data );
}
Function wirtefile ($ fn, $ data)
{
$ Fp = fopen ($ fn, 'WB ');
Fwrite ($ fp, $ data );
Fclose ($ fp );
}
}
/* ------- Word class End -------*/
$ Word = new word;
$ Word-> start ();
Echo $ cout;
$ Wordname = 'word/'.time().'.doc ';
$ Word-> save ($ wordname); // retain and end the word.
?>
'Target = _ blank class = 'unnamed1'> The test has been created. Click here to view details.
}
Else
{
?>
You are not allowed to enter. please enter again!
}
?>