Advertisement
munsking

Untitled

Apr 4th, 2012
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.30 KB | None | 0 0
  1. <?PHP
  2.     include('conf.php');
  3. /*
  4.  * conf.php :
  5.  * $HOST = "YOUR_MYSQL_HOST";
  6.  * $USER = "YOUR_MYSQL_USER";
  7.  * $PASS = "$USER_PASSWORD";
  8.  * $DATA = "YOUR_DATABASE_NAME";
  9.  * $TEST = "TEST_TABLE_NAME";
  10.  * $UMLA = array("ü","ö","ä","Ü","Ö","Ä","ß"); //characters to replace with:
  11.  * $REPL = array("&uuml;","&ouml;","&auml;","&Uuml;","&Ouml;","&Auml;","&szlig"); //herpderp
  12.  *
  13.  */
  14. ?>
  15. <!DOCTYPE html>
  16. <html>
  17. <head>
  18. <title>MCITP WITH MySQL SHIZNIZ</title>
  19. </head>
  20. <body>
  21. <?PHP
  22.  
  23. $query="SELECT * FROM ".$TEST." ORDER BY question_ID ASC";
  24. $LOC = 'mysql:dbname='.$DATA.';host='.$HOST;
  25. //try
  26. //{
  27.     $DBCON = new PDO($LOC, $USER, $PASS);
  28.     $RES=$DBCON->prepare($query);
  29.     $RES->execute();
  30.     $resarr=$RES->fetchAll();
  31. //}
  32. //catch(PDOException $e)
  33. //{
  34.     //var_dump($resarr);
  35.     //echo(count($resarr));
  36. //}
  37.  
  38.  
  39.     /*
  40.     mysql_connect($HOST,$USER,$PASS) or die("cant connect to".$HOST);
  41.     mysql_select_db($DATA) or die("cant select database ".$DATA);
  42.     $result=mysql_query($query) or die("fucker cant query brah");
  43.     */
  44.     $retcount=count($resarr);
  45.     echo('<form name="questions" action="checkanswers.php" method="POST">'."\r\n".'
  46.          <input type="hidden" name="test" value="'.$TEST.'" />'."\r\n".'
  47.          <input type="hidden" name="retcount" value="'.$retcount.'" />'."\r\n");
  48.     while ($resarr = mysql_fetch_assoc($result)){
  49.         $question=str_replace($UMLA,$REPL,$resarr['question']);
  50.         echo("Frage ".$resarr['question_ID']."<br /><br />\r\n".
  51.              $question."<br />\r\n");
  52.         $x=1;
  53.         $a_n_s="answer".$x;
  54.         while(strlen($resarr[$a_n_s])>0){
  55.             if(strlen($resarr[$a_n_s])>0){
  56.                 $resarr[$a_n_s]=str_replace($UMLA,$REPL,$resarr[$a_n_s]);
  57.                 if(strlen($resarr['correct'])<2){
  58.                     echo('<input type="radio" name="'.$resarr['question_ID'].'" value="'.chr($x+64).'" /> '.chr($x+64).': '.$resarr[$a_n_s].'<br />'."\r\n");
  59.                 }else{
  60.                     echo('  <input type="checkbox" name="'.$resarr['question_ID'].'[]" value="'.chr($x+64).'" /> '.chr($x+64).': '.$resarr['answer1'].'<br />'."\r\n");
  61.                 }
  62.             }
  63.             $x++;
  64.             $a_n_s="answer".$x;
  65.         }
  66.         echo("<br /><br />");
  67.     }
  68.     echo('<input type="submit" name="submit" />');
  69. ?>
  70. </body>
  71. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement