King_Of_lords 0 Newbie Poster

Ok Guys I have searched a lot but didnt find proper suitable content
Where In a single php page
1)I want to populate 2 drop down list which display data!
from 2 different tables that is table_designation and table_relation and
2)at same time am going to add one question[by textbox] and point scale [by radio Buttons] and m storing it in table add_questions
3) so inserted value's i want to display and when you click on it then it enables u to update

here is code:----

<?php session_start(); 
 include 'session.php'; 
 include "dbcon.php";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <title>Dashboard | 360D Admin</title>
    <link rel="stylesheet" type="text/css" href="css/reset.css" media="screen" />
    <link rel="stylesheet" type="text/css" href="css/text.css" media="screen" />
    <link rel="stylesheet" type="text/css" href="css/grid.css" media="screen" />
    <link rel="stylesheet" type="text/css" href="css/layout.css" media="screen" />
    <link rel="stylesheet" type="text/css" href="css/nav.css" media="screen" />
    <!--[if IE 6]><link rel="stylesheet" type="text/css" href="css/ie6.css" media="screen" /><![endif]-->
    <!--[if IE 7]><link rel="stylesheet" type="text/css" href="css/ie.css" media="screen" /><![endif]-->    
    <script src="js/jquery-1.6.4.min.js" type="text/javascript"></script>
    <script type="text/javascript" src="js/jquery-ui/jquery.ui.core.min.js"></script>
    <script src="js/jquery-ui/jquery.ui.widget.min.js" type="text/javascript"></script>
    <script src="js/jquery-ui/jquery.ui.accordion.min.js" type="text/javascript"></script>
    <script src="js/jquery-ui/jquery.effects.core.min.js" type="text/javascript"></script>
    <script src="js/jquery-ui/jquery.effects.slide.min.js" type="text/javascript"></script>
    <script src="js/setup.js" type="text/javascript"></script>
    <script type="text/javascript">

        $(document).ready(function () {
            setupLeftMenu();

            $('.datatable').dataTable();
            setSidebarHeight();


        });
    </script>
</head>
<body>
    <div class="container_12">

    <?php    include '360d_header.php';    //added Header it include's session ?>

    <?php include 'menu.php';                //added menubar   <--- ?>



   <div class="clear">
        </div>

<!----------------------------------->

     <div class="grid_2" >
            <div class="box sidemenu">
                <div class="block" id="section-menu">
                    <ul class="section menu">
                        <li><a class="menuitem">Questionarie Management</a>
                            <ul class="submenu">
                                <li><a href="">Add/Edit Point Scale</a> </li>
                                <li><a href="">Questionarie Rule</a> </li>


                            </ul>
                        </li>

                    </ul>
                </div>
            </div>
        </div>

<!----------------------------------->




    <?php //include '360d_submenu.php';    //added submenu <----  ?>
        <div class="grid_10">
            <div class="box round first">

                <h2>Add / Edit Questions </h2>
                <p>          
                </p>
            </div>
        </div>
        <div class="grid_5">
            <div class="box round">
                <h2>
                    Add / Update Questions</h2>
                <div class="block">
                    <p>
    <table style="width:100%">
    <tr> 
        <td>
            <h2>Select Designation</h2>


    <?php        

            $sql = "SELECT desg_name FROM 360d_designation";
            $ds = mysql_query($sql,$con) or die(mysql_error());
            ?>
            <select name ="desg_id">
            <?php    while($row = mysql_fetch_array($ds)){ ?>

            <option value="<?php echo $row["desg_id"]; ?>"> <?php echo $row["desg_name"]; ?></option>
            <?php }  ?>

            </select>

            <?php

                                /*   <?php 
                                                $qry1="Select * from 360d_designation";
                                                $res1=mysql_query($qry1,$con);

                                        ?>
                                    <select name="desg_id">
                                        <?php while ($row = mysql_fetch_array($ds)) { ?> 
                                        <option value="<?php echo $row[0];?>"> <?php echo $row[1];?> </option>
                                        <?php } ?>
                                        </select>
                                    __________________MY CODE____________
                                    echo "<select name ="desg_id">";
            <?php    while($row = mysql_fetch_array($ds)){ 

            echo "<option value='".$row["desg_id"]."'>".$row["desg_name"]."</option>";
            }mysql_free_result($ds);
            echo "</select>";





                                        */





        ?>  

         </td>
        <td>        
            <h2>Select Relation 
            </h2> 
            <?php  //my code   
                    /*  $sql = "SELECT desg_name FROM 360d_designation";
            $ds = mysql_query($sql,$con) or die(mysql_error());
            ?>
            <select name ="desg_id">
            <?php    while($row = mysql_fetch_array($ds)){ ?>

            <option value="<?php echo $row["desg_id"]; ?>"> <?php echo $row["desg_name"]; ?></option>
            <?php }  ?>

            </select>
*/
            ?>



            <?php
                    if(isset($_GET['que_id']))
                    {
                    $q1="select * from 360d_app_questions where que_id=".$_GET['que_id'];
                    $getdata = mysql_query($q1,$con);
                    $fdata = mysql_fetch_array($getdata);
                    }                       
                ?>
            <?php    

                //<select id="id" name="selectstate" onChange="showCity(this.value)">
                $sql = "SELECT rel_name FROM 360d_relations";
                $rs = mysql_query($sql) or die(mysql_error());
            ?>
                echo "<select name = "rel_id">";
        <?php    while($row = mysql_fetch_array($rs)){
                echo "<option value='".$row["rel_id"]."'>".$row["rel_name"]."</option>";
                }mysql_free_result($rs);
                echo "</select>";  
                //$rel = $row;
            ?>
        </td>
    </tr>






<form method="POST" action ="360d_addQuestions.php">
 <table class="form">

        <tr>
                <td class="col1">
                     <label>
                          Enter Question : 
                     </label>
                 </td>

                <td class="col2">
                    <input type="text" name ="Que_detail" id="grumble" class="large"  value="<?php if(isset($fdata)) echo $fdata['dept_name'];?>"  required/> 
                    <input type = "hidden" name="que_id" value="<?php if(isset($fdata)) echo $fdata[0]; else echo "0"; ?>">     
                </td>
        </tr>
         </table>

         <center><h2>Mode of FeedBack</h2></center> 
         <center>
         <table style = "width =100%">
            <tr>
                <td>
            Point Scale <input type="radio" name="cl" value="1" id="1" > 
            Description <input type="radio" name="cl" value="2" id = "2">
                </td>
            </tr>    
        </table>
            <center>

        <input type = "submit" name="btns" value ="Add/Update">
            </center>
        </form>
        <?php 


        if(isset($_POST["btns"])){                                      //<-----Inserting data in to databse

            $que_id = $_POST['que_id'];
            $Que_detail = $_POST['Que_detail'];
            $desg_id = $_POST['desg_id'];
            $rel_id = $_POST['rel_id'];
            $feedback_type = $_POST['c1'];
            $msg="";                
            if($que_id==0) 
              {
                $q = "insert into 360d_app_questions values(null,'{$Que_detail}','{$desg_id}','{$rel_id}','{$feedback_type}')";
                $msg = "added";
              }
            else        
              {
                $q = "update 360d_app_questions set Que_detail ='{$Que_detail}' where que_id=".$que_id;
                $msg = "updated";       
              }
            $res = mysql_query($q,$con);
            if($res)
                echo "<h2>Question {$msg} sucessfully!!</h2>";
            else
                echo "question cannot be {$msg}";                       
         }



    ?>

        </center>



        </p>



                </div>
            </div>
        </div>
        <div class="grid_5">
            <div class="box round">
                <h2>View Questions </h2>
                <div class="block">                    
                    <p> 


                    <?php                        
        /*              $qry = "select * from 360d_app_questions ";
                        $res = mysql_query($qry,$con);
                        if($res && mysql_num_rows($res)>0){
                        echo "<table cellspacing=10>".
                        "<tr><th><h2>Questions Manager </h2></th><th><h2>      Edit</h2></th><th></th></tr>";
                        while($row = mysql_fetch_array($res)){
                        echo "<tr>".

                        "<td><h2>$row[1]</h2></td>".

                            "<td><a href='360d_addquestions.php?dept_id={$row[0]}'> <h2>     ✉ <?php ?></h2></a></td>".
                        "</tr>";


                        }
                        echo "</table>";
        */          ?>







                    </p>
                </div>
            </div>
        </div>
        <div class="clear">
        </div>
    </div>
    <div class="clear">
    </div>

           <?php include 'footer.php';         ?>

</body>
</html>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.