jeudi 6 octobre 2016

query is not running in php

Hi there i am trying to create a screen in php. in which i select scenario and the screen displayed accordingly. but i am stuck in a simple problem that my simple select query is not working which is

$deptQuery = "Select * from mcb_department";
                    echo mysql_real_escape_string($deptQuery);
                    mysql_query($deptQuery) or die("adfasdf");

in same code if change the table name it just work fine, also this table is created in the db as well with the same name i have shared. here is my complete code.

enter code here include "include/conn.php"; include "include/session.php";

   if(isset($_SESSION['logged_user']) && $_SESSION['logged_user'] != '99999'){
     header('location: login.php');
   }

   $query = mysql_query("select curdate() as todayDate");   
    $show = mysql_fetch_array($query);  
    if(isset($show)){                                 
      $todayDate=    $show['todayDate'];                                  
    }

        $group[] = array();



?>

 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://ift.tt/kTyqzh">
<html>
<head>
<title>Untitled Document</title>
<meta Content="no-cache, no-store, must-revalidate" http-Equiv="Cache-Control" />
<meta Content="no-cache" http-Equiv="Pragma" />
<meta Content="0" http-Equiv="Expires" />

    <link href="styles/style.css" type="text/css" rel="stylesheet" />
    <link href="styles/popupstyle.css" type="text/css" rel="stylesheet" />   
    <link href="styles/ts.css" type="text/css" rel="stylesheet" />
    <link href="styles/calendar.css" type="text/css" rel="stylesheet" />         
      <style>
table {
    font-family: arial;
    border-collapse: collapse;
    width: 100%;
    font-size: 11px;
}

td, th {
    border: 1px solid #dddddd;
    text-align: left;
    padding: 3px;
}

tr:nth-child(even) {
    background-color: #dddddd;
}
</style>
</head> 
<body >

</body>

    <select id='select_opt'>
        <option> Select Assigment </option>
        <option value="1"> assign quiz to all Employees </option>
        <option value="2"> assign quiz to Sapcific Group </option>
        <option value="3"> assign quiz to Sapcific Department </option>
        <option value="4"> assign quiz to Sapcific Employee </option>
    </select>

    <!-- all Users -->

    <div id='allUsers' style='margin-left:20px; margin-top: 20px;  width: 50%; height:100px; display: none;' >
        <form action="" mathod="post">
        <select>
            <option value=""> select Quiz</option>
        </select>
        <input type="submit"  >
        </form>
    </div>

    <!-- group -->

    <div id='group' style='margin-left:20px; margin-top: 20px;  width: 50%; height:100px; display: none;' >

        <form action='group_assigment.php' mathod="post">
        <table>
        <tr>
          <th>All <input type="checkbox"> </th>
          <th>Group Name</th>
          <th>Group Code</th>
        </tr>
         <?php  
               $group[] = array();
               $groupQuery = "Select * from mcb_groups";
               $query = mysql_query($groupQuery);
            ?>
        <tr>
            <?php  if($query){
                   while($group = mysql_fetch_array($query)){
                ?>
         <td><input type="checkbox" value="<?php echo $group['group_name']; ?>"></td>
          <td><?php echo $group['group_name']; ?></td>
          <td><?php echo $group['group_code']; ?></td>
        </tr>
            <?php }

                   }  else{ echo "";} ?>
        </table>

            </form>

    </div>

    <!-- 
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    department 
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    -->
 <div id='Department' style='margin-left:20px; margin-top: 20px;  width: 50%; height:100px; display: none;' >

   <form action='group_assigment.php' mathod="post">

       <table>
           <tr>
             <th>all <input type="checkbox"> </th>
             <th>name</th>
             <th>code</th>
             <th>group</th>
           </tr>
           <tr>
               <?php
                    $deptQuery = "Select * from mcb_department";
                    echo mysql_real_escape_string($deptQuery);
                    mysql_query($deptQuery);
               ?>
               <td><input type="checkbox"></td>
               <td>code</td>
               <td>name</td>
               <td>group</td>
           </tr>

         </table>
        <input type="submit" >
        </form>
    </div>

    <!-- 
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
        Employee 
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    -->    

        <div id='employee' style='margin-left:20px; margin-top: 20px;  width: 50%; height:100px; display: none;' >
         <form action="" mathod="post">
            <label>employee id : </label><input type="text" >
            <input type="submit" >
         </form>
    </div>


<script language="javascript" type="text/javascript">
 var elem = document.getElementById("select_opt");
            elem.onchange = function(){

                            console.log("yes i am running");
                            if( document.getElementById("select_opt").value == "1" ){

                                document.getElementById("allUsers").style.display = "Block";
                                document.getElementById("group").style.display = "none";
                                document.getElementById("Department").style.display = "none";
                                document.getElementById("employee").style.display = "none";

                            }
                            else if( document.getElementById("select_opt").value == "2" ){

                                document.getElementById("group").style.display = "Block";
                                document.getElementById("allUsers").style.display = "none";
                                document.getElementById("Department").style.display = "none";
                                document.getElementById("employee").style.display = "none";

                            }
                            else if( document.getElementById("select_opt").value == "3" ){

                                document.getElementById("Department").style.display = "block";
                                document.getElementById("group").style.display = "none";
                                document.getElementById("allUsers").style.display = "none";
                                document.getElementById("employee").style.display = "none";



                            }
                            else if( document.getElementById("select_opt").value == "4" ){

                                document.getElementById("employee").style.display = "block";
                                document.getElementById("Department").style.display = "none";
                                document.getElementById("group").style.display = "none";
                                document.getElementById("allUsers").style.display = "none";
                            }

                            else{


                            }



            };
 </script> 

</

html>

regard, Shafee jan




Aucun commentaire:

Enregistrer un commentaire