• 17-11-2017, 21:51:20
    #1
    Arkadaşlar kodun neresine yazsam reklam göstermiyor nerede hata yapıyorum isteğim butonun altında olsun reklam fakat göstermiyor
    php dosyasınıda atıyorum size bi bakarmısınız.

    questions.rar - 2 KB
  • 17-11-2017, 21:54:30
    #2
    kodu paylaşırsan eğer baksak daha iyi olur
  • 17-11-2017, 21:58:38
    #3
    <?php
    session_start();
    ob_Start();
    ?>
    <?php
    require 'config.php';
    $category='';
     if(!empty($_POST['name'])){
         $name=$_POST['name'];
         $category=$_POST['category'];
         mysql_query("INSERT INTO users (id, user_name,score,category_id)VALUES ('NULL','$name',0,'$category')") or die(mysql_error());
         $_SESSION['name']= $name;
         $_SESSION['id'] = mysql_insert_id();
     }
    $category=$_POST['category'];
    $query_ek = "";
    if($_POST['donem']){
        
        $donem = mysql_real_escape_string(trim($_POST['donem']));
        $query_ek = " and donem = '$donem'";
    }
    if($_POST['sinav']){
        
        $sinav = mysql_real_escape_string(trim($_POST['sinav']));
        $query_ek = " and sinav = '$sinav'";
    }
    $soru_sayisi_response=mysql_query("select count(id) from questions where category_id = $category $query_ek")   or die(mysql_error());
    $soru_sayisi_result = mysql_fetch_row($soru_sayisi_response);
        
    if(!empty($_SESSION['username'])){
    ?>
    <!DOCTYPE html>
    <html>
        <head>
            <title>Aöf Çıkmış Sorular || Aöf Soru Bankası</title>
            <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
            <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no" />
            <!-- Bootstrap -->
            <link href="css/bootstrap.min.css" rel="stylesheet" media="screen">
            <link href="css/style.css" rel="stylesheet" media="screen">
            <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
            <!--[if lt IE 9]>
            <script src="../../assets/js/html5shiv.js"></script>
            <script src="../../assets/js/respond.min.js"></script>
            <![endif]-->
            
            <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
            <script src="js/jquery-1.10.2.min.js"></script>
            <!-- Include all compiled plugins (below), or include individual files as needed -->
            <script src="js/bootstrap.min.js"></script>
            <script src="js/jquery.validate.min.js"></script>
            <script src="js/countdown.js"></script>
            <style>
                .container {
                    margin-top: 110px;
                }
                .error {
                    color: #B94A48;
                }
                .form-horizontal {
                    margin-bottom: 0px;
                }
                .hide{display: none;}
            </style>
        </head>
        <body>
            <header>
                <p class="text-center">
                    Hoşgeldin <?php if(!empty($_SESSION['username'])){echo $_SESSION['username'];}?>
                </p>
            </header>
            <div id='timer'>
                <script type="application/javascript">
                var myCountdownTest = new Countdown({
                                        time: <?php echo ($soru_sayisi_result[0] * 60); ?>,
                                        width:200,
                                        height:80,
                                        rangeHi:"minute"
                                        });
               </script>
                
            </div>
            
            <div class="container question">
                <div class="col-xs-12 col-sm-8 col-md-8 col-xs-offset-4 col-sm-offset-3 col-md-offset-3">
                    
                    <form class="form-horizontal" role="form" id='login' method="post" action="result.php">
                        <?php
                        $res = mysql_query("select * from questions where category_id=$category $query_ek ORDER BY RAND()") or die(mysql_error());
                        $rows = mysql_num_rows($res);
                        $i=1;
                    while($result=mysql_fetch_array($res)){?>
                        
                        
                        <?php if($i==1){?>        
                        <div id='question<?php echo $i;?>' class='cont'>
                        <p class='questions' id="qname<?php echo $i;?>"> <?php echo $i?>.<?php echo $result['question_name'];?></p>
                        <label>
                        <input type="radio" value="1" id='radio1_<?php echo $result['id'];?>' name='<?php echo $result['id'];?>'/><?php echo $result['answer1'];?>
                        </label>
                       <br/>
                        <label>
                        <input type="radio" value="2" id='radio1_<?php echo $result['id'];?>' name='<?php echo $result['id'];?>'/><?php echo $result['answer2'];?>
                        </label>
                        <br/>
                        
                        <label>
                        <input type="radio" value="3" id='radio1_<?php echo $result['id'];?>' name='<?php echo $result['id'];?>'/><?php echo $result['answer3'];?>
                        </label>
                        <br/>
                        <label>
                        <input type="radio" value="4" id='radio1_<?php echo $result['id'];?>' name='<?php echo $result['id'];?>'/><?php echo $result['answer4'];?>
                        </label>
                        <br/>
                        
                        <label>
                        <input type="radio" value="5" id='radio1_<?php echo $result['id'];?>' name='<?php echo $result['id'];?>'/><?php echo $result['answer5'];?>
                        </label>
                                                                                            
                        <br/>
                        <button id='<?php echo $i;?>' class='next btn btn-success' type='button'>İleri</button>
                        </div>    
                          
                         <?php }elseif($i<1 || $i<$rows){?>
                        
                           <div id='question<?php echo $i;?>' class='cont'>
                        <p class='questions' id="qname<?php echo $i;?>"><?php echo $i?>.<?php echo $result['question_name'];?></p>
                        <label>
                        <input type="radio" value="1" id='radio1_<?php echo $result['id'];?>' name='<?php echo $result['id'];?>'/><?php echo $result['answer1'];?>
                        </label>
                        <br/>
                        <label>
                        <input type="radio" value="2" id='radio1_<?php echo $result['id'];?>' name='<?php echo $result['id'];?>'/><?php echo $result['answer2'];?>
                        </label>
                        <br/>
                        <label>
                        <input type="radio" value="3" id='radio1_<?php echo $result['id'];?>' name='<?php echo $result['id'];?>'/><?php echo $result['answer3'];?>
                        </label>
                        <br/>
                        <label>
                        <input type="radio" value="4" id='radio1_<?php echo $result['id'];?>' name='<?php echo $result['id'];?>'/><?php echo $result['answer4'];?>
                        </label>
                        <br/>
                        
                        <label>
                        <input type="radio" value="5" id='radio1_<?php echo $result['id'];?>' name='<?php echo $result['id'];?>'/><?php echo $result['answer5'];?>
                        </label>
                                                                                            
                        <br/>
                        <button id='<?php echo $i;?>' class='previous btn btn-success' type='button'>Geri</button>                    
                        <button id='<?php echo $i;?>' class='next btn btn-success' type='button' >İleri</button>
                        
                        <button id="4" class="next btn btn-success" style="margin-top: 15px; margin-right: 92px" type="submit">Bitir</button>
                        
                        </div>
                          
                          
                          
                            
                            
                       <?php }elseif($i==$rows){?>
                        <div id='question<?php echo $i;?>' class='cont'>
                        <p class='questions' id="qname<?php echo $i;?>"><?php echo $i?>.<?php echo $result['question_name'];?></p>
                        <label>
                        <input type="radio" value="1" id='radio1_<?php echo $result['id'];?>' name='<?php echo $result['id'];?>'/><?php echo $result['answer1'];?>
                        </label>
                        <br/>
                        <label>
                        <input type="radio" value="2" id='radio1_<?php echo $result['id'];?>' name='<?php echo $result['id'];?>'/><?php echo $result['answer2'];?>
                        </label>
                        <br/>
                        <label>
                        <input type="radio" value="3" id='radio1_<?php echo $result['id'];?>' name='<?php echo $result['id'];?>'/><?php echo $result['answer3'];?>
                        </label>
                        <br/>
                        <label>
                        <input type="radio" value="4" id='radio1_<?php echo $result['id'];?>' name='<?php echo $result['id'];?>'/><?php echo $result['answer4'];?>
                        </label>
                        <br/>
                        <label>
                         <input type="radio" value="5" id='radio1_<?php echo $result['id'];?>' name='<?php echo $result['id'];?>'/><?php echo $result['answer5'];?>
                        </label>
                        <br/>
                        
                        
                        <button id='<?php echo $i;?>' class='previous btn btn-success' type='button'>Geri</button>                    
                        <button id='<?php echo $i;?>' class='next btn btn-success' type='submit'>Bitir</button>
                        </div>
                        <?php } $i++;} ?>
                        
                        <input type="hidden" name="category" value="<?php echo $category;?>">
                        <input type="hidden" name="donem" value="<?php echo $donem;?>">
                        <input type="hidden" name="sinav" value="<?php echo $sinav;?>">
                    </form>
                </div>
            </div>
    <?php
    if(isset($_POST[1])){
       $keys=array_keys($_POST);
       $order=join(",",$keys);
      
       //$query="select * from questions id IN($order) ORDER BY FIELD(id,$order)";
      // echo $query;exit;
      
       $response=mysql_query("select id,answer from questions where id IN($order) ORDER BY FIELD(id,$order)")   or die(mysql_error());
       $right_answer=0;
       $wrong_answer=0;
       $unanswered=0;
       while($result=mysql_fetch_array($response)){
           if($result['answer']==$_POST[$result['id']]){
                   $right_answer++;
               }else if($_POST[$result['id']]==5){
                   $unanswered++;
               }
               else{
                   $wrong_answer++;
               }
          
       }
      
      
       echo "right_answer : ". $right_answer."<br>";
       echo "wrong_answer : ". $wrong_answer."<br>";
       echo "unanswered : ". $unanswered."<br>";
    }
    ?>
            
            
            <script>
            $('.cont').addClass('hide');
            count=$('.questions').length;
             $('#question'+1).removeClass('hide');
            
             $(document).on('click','.next',function(){
                 last=parseInt($(this).attr('id'));    
                 nex=last+1;
                 $('#question'+last).addClass('hide');
                
                 $('#question'+nex).removeClass('hide');
             });
            
             $(document).on('click','.previous',function(){
                 last=parseInt($(this).attr('id'));    
                 pre=last-1;
                 $('#question'+last).addClass('hide');
                
                 $('#question'+pre).removeClass('hide');
             });
                
             setTimeout(function() {
                 $("form").submit();
              }, <?php echo ($soru_sayisi_result[0] * 60); ?>000);
            </script>
        </body>
    </html>