input from same php page

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sanjay123456
    New Member
    • Sep 2006
    • 125

    #1

    input from same php page

    Sir ,


    The followoing code for open a question from database and user click
    answer and click the next question but its not work


    [PHP]

    <?php
    session_start() ;
    if (!isset($_SESSI ON['count']))

    $_SESSION['count'] = 1;
    if (isset($_POST['submitted'])) {

    $con = mysql_connect(" localhost","roo t","123456") ;

    if (!$con)
    {
    die('Could not connect: ' . mysql_error());
    }

    mysql_select_db ("my_db", $con);
    $sql="select * from quest where count = ".$_SESSION['count']."";
    echo $sql;
    $r=mysql_query( $sql);

    if (!r)
    {
    die('Error: ' . mysql_error());
    exit();
    }

    while($row = mysql_fetch_arr ay($r))
    //while($_SESSION['count'] <<3)
    {?>
    <p style="color: #0000ff"><?php echo
    $row['que'];?><table border='0'><tr> <td valign='top'><i nput
    type='radio' name='quiz' value='4' /></td><td><?php echo
    $row['op1'];?><br></td></tr><tr><td valign='top'><i nput
    type='radio' name='quiz' value='3' /></td><td><?php echo
    $row['op2'];?><br></td></tr><tr><td valign='top'><i nput
    type='radio' name='quiz' value='2' /></td><td><?php echo
    $row['op3'];?><br></td></tr><tr><td valign='top'><i nput
    type='radio' name='quiz' value='1' /></td><td><?php echo
    $row['op4'];?><br></td></tr></table><br></p></form>

    <?php

    $que=$_POST['que'];
    $quiz=$_POST['quiz'];
    $sql2="select answer from answerquest where que like ".$que." and
    correctoption like ".$quiz."";
    $run=mysql_quer y($sql2);
    if(mysql_num_ro ws($run) == ""){
    echo "wrong answer";
    }else{
    echo "right answer";
    }


    }
    mysql_close($co n);

    echo 'This is question no. '.$_SESSION['count'];
    $_SESSION['count'] += 1;
    }?>




    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <html><head><ti tle>Questionnai re</title></head>
    <body>
    <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
    <input type="hidden" name="que" value="<?php=$r ow['que']?>">
    <input type="submit" VALUE="Click here for the next question <?php
    echo $_SESSION['count']; ?>" />
    <input type="hidden" name="submitted " value="1" />
    </form></body></html>

    [/PHP]


    sanjay
  • ronverdonk
    Recognized Expert Specialist
    • Jul 2006
    • 4259

    #2
    What is not working? This is not a clear concise description of your problem. What really hinders me here, is that I have the strong feeling that, seeing your past 6 threads about the same subject and script, you are building a complete student application almost from scratch and that you let our members build it for you.

    Maybe it is time you did some serious beginner's tutorials on PHP and MySQL. There are plenty available on the web.

    Our members are always willing to help, but it could have saved a lot of them quite a lot of time if you had stated your objective and goal right from the start.

    Ronald :cool:

    Comment

    Working...