Can't retrieve data properly from database in php -


i have 2 entries in tblstudentdetails having rollno = 0 , 1 whenever try retrieve data database first record i.e. rollno = 0 here code:

<?php      unset($_session['rollno']);     unset($_session['studentname']);     unset($_session['course']);      include_once 'includes/dbconnection.php';      //echo $_post['txtrollno'];      if ($_post['btnsubmit'] == 'submit')         {            if ($_post['txtrollno'] != '')                {                    $query = "select studentname, course tblstudentdetails rollno = '$_post[txtrollno]'";                    $result = mysql_query($query);                     $rowcount = mysql_num_rows($result);                     if ($rowcount == 0)                        {                             echo "you have entered incorrect roll no";                            //header ('location: index.php');                        }                    else                        {                            while ($row = mysql_fetch_assoc($result))                                {                                    $studentname = $row['studentname'];                                    $course = $row['course'];                                }                             $_session['rollno'] = $_post['txtrollno'];                            $_session['studentname'] = $studentname;                            $_session['course'] = $course;                             header ('location: selecteduserdetails.php');                        }                }            else                {                     echo "please enter roll no.";                     //header ('location: index.php');                }         } ?>  <html>     <head>         <title>online exam</title>         <style type = "text/css">             h1                 {                     color : dodgerblue;                     text-align : center                 }             hr                 {                     color : dodgerblue                 }             label                 {                     vertical-align : bottom;                     font-size : 20                 }             tr                 {                     height : 30;                     background : white;                     color : black;                     font-size : 20                 }         </style>    </head>      <body bgcolor = "black" text = "white">         <center>             <table align = "center">                 <tr>                     <?php include 'includes/header.html'; ?>                 </tr>                 <tr>                     <td>                         <table>                             <tr>                                 <form name = "frmmain" method = "post" action = "<?php echo $php_self ?>" enctype = "multipart/form-data">                                     <td>                                         enter roll no. :                                      </td>                                     <td>                                         <input type = "text" name = "txtrollno" />                                     </td>                                     <td>                                         <input type = "submit" name = "btnsubmit" value = "submit" />                                     </td>                                 </form>                             </tr>                         </table>                     </td>                 </tr>             </table>                 </center>     </body> </html> 

in selecteduserpage tried check value of $_session['rollno'] null. can problem in above code?

you have not started session session_start().


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

javascript - addthis share facebook and google+ url -

ios - Show keyboard with UITextField in the input accessory view -