PHP generates the code for the Word document, which is a simple PHP code to produce the quiz paper
<?php
Initializing session
Session_Start ();
Contains database connection files and header files
?>
<title> Test paper Generation </title>
<link href= "Css/style.css" rel= "stylesheet" type= "Text/css" >
?
Include (' head.php ');
Require (' dbconnect.php ');
?>
? 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 (); Return array
$i = 0; Array subscript
$query _result= @mysql_query ($sql, $conn);
while ($row = @mysql_fetch_object ($query _result))
{
$i + +;
$cout. = $i. "";
$cout. = "Problem Difficulty:". $row->difficulty. " <br> ";
$cout. = "". $row->content. <br><br> ";
}//while
?>
<?php
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);//save Word and end.
?>
<div align= "center" ><a href= "<?php echo $wordname?>" Target=_blank class= "unnamed1" > Quiz paper has been generated, Please click here to view </a>
? Php
}
Else
{
?>
</div>
<div align= "center" ><span class= "unnamed1" > You have not entered enough conditions, please re-enter! </span>
? Php
}
?>
</div>