SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Guru ujjwal's Avatar
    Join Date
    Oct 2004
    Location
    kolkata
    Posts
    821
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Value is not incresaing or not entering in if branching

    Hello all,
    I want to do that user submit his question and answer(In my code qid and answer will store only in a variable not full question only qid comes for storing purpose)
    and then I want to check whether the qisd and answer are right or not .If it is right then increased by point 1.
    My code is that
    PHP Code:
    //storing the answer and questions(qid which are coming from questionare table
    $sub=empty($_POST['B1'])?'':$_POST['B1'];
        
    $user=empty($_POST['user'])?'':$_POST['user'];
        
    $uid=empty($_POST['uid'])?'':$_POST['uid'];
        
    $ans1=empty($_POST['1'])?'':$_POST['1'];
        
    $ans2=empty($_POST['2'])?'':$_POST['2'];
        
    $ans3=empty($_POST['3'])?'':$_POST['3'];
        
    $ans4=empty($_POST['4'])?'':$_POST['4'];
        
    $ans5=empty($_POST['5'])?'':$_POST['5'];
        
    $ans6=empty($_POST['6'])?'':$_POST['6'];
        
    $ans7=empty($_POST['7'])?'':$_POST['7'];
        
    $ans8=empty($_POST['8'])?'':$_POST['8'];
        
    $ans9=empty($_POST['9'])?'':$_POST['9'];
        
    $ans10=empty($_POST['10'])?'':$_POST['10'];

        
    $qnum1=empty($_POST['qnum1'])?'':$_POST['qnum1'];
        
    $qnum2=empty($_POST['qnum2'])?'':$_POST['qnum2'];
        
    $qnum3=empty($_POST['qnum3'])?'':$_POST['qnum3'];
        
    $qnum4=empty($_POST['qnum4'])?'':$_POST['qnum4'];
        
    $qnum5=empty($_POST['qnum5'])?'':$_POST['qnum5'];
        
    $qnum6=empty($_POST['qnum6'])?'':$_POST['qnum6'];
        
    $qnum7=empty($_POST['qnum7'])?'':$_POST['qnum7'];
        
    $qnum8=empty($_POST['qnum8'])?'':$_POST['qnum8'];
        
    $qnum9=empty($_POST['qnum9'])?'':$_POST['qnum9'];
        
    $qnum10=empty($_POST['qnum10'])?'':$_POST['qnum10'];
        
        if(
    $sub=="Click") {
            
    $sp="select * from questionare";
    $resultp=mysql_query($sp) or
    die(
    "The point table has some problem");
    $point=0;
    $rownum=mysql_num_rows($resultp);

     while(
    $qu mysql_fetch_array($resultp))
     {
         
        echo 
    "Your point2 is $point";     
        for(
    $k=1;$k<=$rownum;$k++) {         
    if((
    $qu['qid']==$qnumk) && ($qu['result']==$ansk)) {
        
    $point++;
        echo 
    "Your point1 is $point";         
             }
         }
          
     }
    echo 
    "Your point is $point";
    //form is here 
    I want to count how many point user has gained but here there is only show 0
    In questionare table, qid is int and result is varchar.
    Will u guide how can i count each user scored how much point after submitting 10 anser .
    Thanks.
    -::Ujjwal::-
    Visit My Site

  2. #2
    SitePoint Enthusiast
    Join Date
    Mar 2005
    Posts
    68
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by ujjwal
    Hello all,
    I want to do that user submit his question and answer(In my code qid and answer will store only in a variable not full question only qid comes for storing purpose)
    and then I want to check whether the qisd and answer are right or not .If it is right then increased by point 1.
    My code is that
    PHP Code:
    //storing the answer and questions(qid which are coming from questionare table
    $sub=empty($_POST['B1'])?'':$_POST['B1'];
        
    $user=empty($_POST['user'])?'':$_POST['user'];
        
    $uid=empty($_POST['uid'])?'':$_POST['uid'];
        
    $ans1=empty($_POST['1'])?'':$_POST['1'];
        
    $ans2=empty($_POST['2'])?'':$_POST['2'];
        
    $ans3=empty($_POST['3'])?'':$_POST['3'];
        
    $ans4=empty($_POST['4'])?'':$_POST['4'];
        
    $ans5=empty($_POST['5'])?'':$_POST['5'];
        
    $ans6=empty($_POST['6'])?'':$_POST['6'];
        
    $ans7=empty($_POST['7'])?'':$_POST['7'];
        
    $ans8=empty($_POST['8'])?'':$_POST['8'];
        
    $ans9=empty($_POST['9'])?'':$_POST['9'];
        
    $ans10=empty($_POST['10'])?'':$_POST['10'];

        
    $qnum1=empty($_POST['qnum1'])?'':$_POST['qnum1'];
        
    $qnum2=empty($_POST['qnum2'])?'':$_POST['qnum2'];
        
    $qnum3=empty($_POST['qnum3'])?'':$_POST['qnum3'];
        
    $qnum4=empty($_POST['qnum4'])?'':$_POST['qnum4'];
        
    $qnum5=empty($_POST['qnum5'])?'':$_POST['qnum5'];
        
    $qnum6=empty($_POST['qnum6'])?'':$_POST['qnum6'];
        
    $qnum7=empty($_POST['qnum7'])?'':$_POST['qnum7'];
        
    $qnum8=empty($_POST['qnum8'])?'':$_POST['qnum8'];
        
    $qnum9=empty($_POST['qnum9'])?'':$_POST['qnum9'];
        
    $qnum10=empty($_POST['qnum10'])?'':$_POST['qnum10'];
        
        if(
    $sub=="Click") {
            
    $sp="select * from questionare";
    $resultp=mysql_query($sp) or
    die(
    "The point table has some problem");
    $point=0;
    $rownum=mysql_num_rows($resultp);

     while(
    $qu mysql_fetch_array($resultp))
     {
         
        echo 
    "Your point2 is $point";     
        for(
    $k=1;$k<=$rownum;$k++) {         
    if((
    $qu['qid']==$qnumk) && ($qu['result']==$ansk)) {
        
    $point++;
        echo 
    "Your point1 is $point";         
             }
         }
          
     }
    echo 
    "Your point is $point";
    //form is here 
    I want to count how many point user has gained but here there is only show 0
    In questionare table, qid is int and result is varchar.
    Will u guide how can i count each user scored how much point after submitting 10 anser .
    Thanks.
    Try this, I think this should work:

    PHP Code:
    //storing the answer and questions(qid which are coming from questionare table
    $sub=empty($_POST['B1'])?'':$_POST['B1'];
        
    $user=empty($_POST['user'])?'':$_POST['user'];
        
    $uid=empty($_POST['uid'])?'':$_POST['uid'];

    /* YOU DON'T NEED ALL THIS, just use $_POST

        $ans1=empty($_POST['1'])?'':$_POST['1'];
        $ans2=empty($_POST['2'])?'':$_POST['2'];
        $ans3=empty($_POST['3'])?'':$_POST['3'];
        $ans4=empty($_POST['4'])?'':$_POST['4'];
        $ans5=empty($_POST['5'])?'':$_POST['5'];
        $ans6=empty($_POST['6'])?'':$_POST['6'];
        $ans7=empty($_POST['7'])?'':$_POST['7'];
        $ans8=empty($_POST['8'])?'':$_POST['8'];
        $ans9=empty($_POST['9'])?'':$_POST['9'];
        $ans10=empty($_POST['10'])?'':$_POST['10'];

            $qnum1=empty($_POST['qnum1'])?'':$_POST['qnum1'];
        $qnum2=empty($_POST['qnum2'])?'':$_POST['qnum2'];
        $qnum3=empty($_POST['qnum3'])?'':$_POST['qnum3'];
        $qnum4=empty($_POST['qnum4'])?'':$_POST['qnum4'];
        $qnum5=empty($_POST['qnum5'])?'':$_POST['qnum5'];
        $qnum6=empty($_POST['qnum6'])?'':$_POST['qnum6'];
        $qnum7=empty($_POST['qnum7'])?'':$_POST['qnum7'];
        $qnum8=empty($_POST['qnum8'])?'':$_POST['qnum8'];
        $qnum9=empty($_POST['qnum9'])?'':$_POST['qnum9'];
        $qnum10=empty($_POST['qnum10'])?'':$_POST['qnum10'];
    */    
        
    if($sub=="Click") {
            
    $sp="select * from questionare";
                    
    $resultp=mysql_query($sp) or
                    die(
    "The point table has some problem");
                   
    $point=0;
                   
    $rownum=mysql_num_rows($resultp);

     while(
    $qu mysql_fetch_array($resultp))
     {
        echo 
    "Your point2 is $point";     
        for(
    $k=1$k<=$rownum$k++) {         
               if( (
    $qu['qid']==$_POST['qnum'.$k]) && ($qu['result']==$_POST[$k] )) {
             
    $point++;
             echo 
    "Your point1 is $point";         
               }
           }
         
     }
    echo 
    "Your point is $point";
    //form is here 


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •