下拉菜单在编辑时没有选择php中的选定选项

时间:2015-02-26 06:09:45

标签: php

我在添加时选择了选项,但所选的选项不在编辑下拉菜单中。
问题是什么?

Edit Appointment.php:

<?php
include_once 'config.php';
$id = $_REQUEST['id'];
$query="SELECT p.*,u.fileno FROM patients AS p,users AS u WHERE p.id_patient='$id' AND p.users_id_user=u.id_user";
$resultPatient=$db->select($query);
if(isset($_POST['requesttype'])&&$_POST['requesttype'] == 'editPatient'){
    $updateInfo=array();
    $updateInfo['name'] = $_REQUEST['name'];
    $updateInfo['email'] = $_REQUEST['email'];
    $updateInfo['age'] = $_REQUEST['age'];
    /*$updateInfo['age'] = $_REQUEST['age'];
    $updateInfo['gender'] = $_REQUEST['gender'];*/
    $updateInfo['phone'] = str_replace(array('(',')',' ','-'), array('','','',''),$_REQUEST['phone']);
    $updateInfo['date'] = date('d-m-Y', strtotime($_REQUEST['date']));
    $updateInfo['time'] = $_REQUEST['time'];
    $updateInfo['confirm_status'] = 'c';
    $date=date('Y-m-d H:i:s');
    $updateInfo['date_updated']=$date;
    $updateCondition=" id_patient='".$id."'";
    $res=$db->update('patients', $updateInfo,$updateCondition);
    $id=$resultPatient[0]['users_id_user'];
    $where="t.users_id_user='$id' AND";
    $query="SELECT t.device_id,t.platforms_id_platform as id_platform FROM tokens as t WHERE $where t.device_id!=''";
    $resultTokens=$db->select($query);
    if($resultTokens)
    {
        include_once 'Gcm.php';
        include_once 'Apns.php';
        $deviceTokens=array();
        $deviceTokens1=array();
        $alert='Your appointment is confirmed on '.$updateInfo['date'].' at '.$updateInfo['time'];
        foreach($resultTokens as $token)
        {
            if($token['id_platform']=='1'&&$token['device_id']!='')
                $deviceTokens[]=$token['device_id'];
            if($token['id_platform']=='2'&&$token['device_id']!='')
                $deviceTokens1[]=$token['device_id'];
        }
        if(count($deviceTokens)>0)
        {
            $apns=new Apns();
            $apns->apnsPush($deviceTokens,$alert);
        }
        if(count($deviceTokens1)>0)
        {
            $gcm = new GCM();
            $message = array("m" => $alert);
            $result = $gcm->send_notification($deviceTokens1,$message);
        }
    }
    header("Location:appointments.php?m=u");
} 
$querySlot = "SELECT * FROM slots";
$resultSlot=$db->select($querySlot);

$query="select * from photos where type='service'";
$resultUsers1=$db->select($query);
include_once 'header.php';

?>
<script type="text/javascript" src="js/jquery.timepicker.js"></script>
  <link rel="stylesheet" type="text/css" href="js/jquery.timepicker.css" />
<script>
                $(function() {
                    $('#basicExample').timepicker();
                });
            </script>
<!-- Sidebar begins -->
<div id="sidebar">

    <!-- Left Main menu begins -->
        <?php include_once 'menu.php'; ?>
    <!-- Left Main menu ends -->


    <!-- Secondary nav --> 
    <div class="secNav">
        <div class="secWrapper">
            <!--div class="secTop">
            </div-->

            <!-- Tabs container -->
            <div id="tab-container" class="tab-container">
            <div id="general">

                    <!-- Sidebar big buttons -->
                     <div id="general" style="display: block;" class="active">
                      <ul class="subNav">
                        <li><a href="add_appointment.php" title=""><span class="icos-images2"></span>Add Appointment</a></li>
                        <li class="activeli"><a href="appointments.php" title="" class="this"><span class="icos-images2"></span>View/Edit Appointments</a></li>
                        <li><a href="appointments_history.php" title=""><span class="icos-images2"></span>Appointments History</a></li>
                        <li><a href="reminder_settings.php" title=""><span class="icos-images2"></span>View/Edit Reminder Settings</a></li>
                        <li><a href="add_reminder_settings.php" title=""><span class="icos-images2"></span>Add Reminder Settings</a></li>
                        <li><a href="medicine_reminder_settings.php" title=""><span class="icos-images2"></span>View/Edit Medicine Reminder Settings</a></li>
                        <li><a href="add_medicine_reminder_settings.php" title=""><span class="icos-images2"></span>Add Medicine Reminder Settings</a></li>
                    </ul>
                </div>   
                </div>                

            </div>


       </div> 
       <div class="clear"></div>
   </div>
</div>
<!-- Sidebar ends -->


<!-- Content begins -->
<div id="content">
    <div class="contentTop">
        <span class="pageTitle"><span class="icon-screen"></span>Edit Appointment</span>
        <div class="clear"></div>
    </div>

    <!-- Breadcrumbs line -->
    <div class="breadLine">
        <div class="bc">
            <ul id="breadcrumbs" class="breadcrumbs">
                <li><a href="#">Dashboard</a></li>
                <li><a href="appointments.php">Appointments</a></li>
                <li class="current"><a href="#" title="">Edit Appointment</a></li>
            </ul>
        </div>

    </div>
    <!-- Main content -->
    <div class="wrapper">


        <div class="fluid">
            <form name="formEditAppointment" id="usualValidate" class="main" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST" enctype="multipart/form-data">
                <div class="widget grid6 chartWrapper" style="width:100%;min-height:550px;">
                    <div class="whead"><h6>Edit Appointment Information</h6><div class="clear"></div></div>
                    <div class="formRow">
                        <div class="grid3"><label>File No:<span class="req">*</span></label></div>
                        <div class="grid9"><?php echo stripslashes($resultPatient[0]['fileno']);?></div>
                        <div class="clear"></div>
                    </div>
                    <div class="formRow">
                        <div class="grid3"><label>Name:<span class="req">*</span></label></div>
                        <div class="grid9"><input type="text" class="required" name="name" id="name" value="<?php echo stripslashes($resultPatient[0]['name']);?>"/></div>
                        <div class="clear"></div>
                    </div>
                    <div class="formRow">
                        <div class="grid3"><label>Email:</label></div>
                        <div class="grid9"><input type="text" class="email" name="email" id="email" value="<?php echo stripslashes($resultPatient[0]['email']);?>"/></div>
                        <div class="clear"></div>
                    </div>
                    <div class="formRow">
                        <div class="grid3"><label>Age:</label></div>
                        <div class="grid9"><input type="text" class="required" name="age" id="age" value="<?php echo stripslashes($resultPatient[0]['age']);?>"/></div>
                        <div class="clear"></div>
                    </div>
                    <div class="formRow">
                        <div class="grid3"><label>Service:<span class="req">*</span></label></div>
                        <div class="grid9 searchDrop"><select data-placeholder="select service..." class="select" style="width: 100%" name="id_service"> 

                            <?php if($resultUsers1 && count($resultUsers1)>0)
                                foreach($resultUsers1 as $user)
                                {?>                
                                <option value="<?php echo $user['id_photo']?>"<?php if($user['id_photo']==$user['title']) { ?> selected="selected" <?php } ?>><?php echo $user['title'];?></option>
                            <?php }?>
                            </select></div>
                        <div class="clear"></div>
                    </div>

                    <div class="formRow">
                        <div class="grid3"><label>Phone:</label></div>
                        <div class="grid9"><input type="text" name="phone" id="phone" value="<?php echo stripslashes($resultPatient[0]['phone']);?>"/></div>
                        <div class="clear"></div>
                    </div>
                    <div class="formRow">
                        <div class="grid3"><label>Date:</label></div>
                        <div class="grid9"><input type="text" class="required datepicker" name="date" id="date" value="<?php echo date('d-m-Y',strtotime($resultPatient[0]['date']));?>"/></div>
                        <div class="clear"></div>
                    </div>
                    <div class="formRow">
                        <div class="grid3"><label>Time:</label></div>
                        <div class="grid9 searchDrop">
                           <input id="basicExample" type="text" name="time"  class="time" value="<?php echo stripslashes($resultPatient[0]['time']);?>" style="width:80px"/>
                        </div>
                        <div class="clear"></div>
                    </div>
                    <input type="hidden" value="<?php echo $id; ?>" name="id" id="id_patient"/>
                    <input type="hidden" value="editPatient" name="requesttype"/>
                    <div class="formRow">

                        <div class="formSubmit">

                            <input class="buttonM bRed" id="next1" value="Save" type="submit">
                            <div class="clear"></div>
                        </div>     <div class="clear"></div>                   
                    </div>
                    <div class="clear"></div></div>

            </form>
       </div>

    </div>
    <!-- Main content ends -->

</div>
<!-- Content ends -->

</body>
</html>

Add Appointment.php:

<?php
include_once 'config.php';
if(isset($_POST['requesttype'])&&$_POST['requesttype'] == 'addPatient'){
    $insertInfo=array();
    $insertInfo['users_id_user'] = $_REQUEST['id_user'];
    $insertInfo['name'] = $_REQUEST['name'];
    $insertInfo['email'] = $_REQUEST['email'];
    $insertInfo['age'] = $_REQUEST['age'];
    $insertInfo['gender'] = $_REQUEST['act'];
    $insertInfo['service_id']=$_REQUEST['id_service'];
    $insertInfo['phone'] = str_replace(array('(',')',' ','-'), array('','','',''),$_REQUEST['phone']);
    $insertInfo['date'] = date('d-m-Y', strtotime($_REQUEST['date']));
    $insertInfo['time'] = $_REQUEST['time'];
    $insertInfo['confirm_status'] = 'c';
    $date=date('Y-m-d H:i:s');
    $insertInfo['date_created']=$date;
    $insertInfo['date_updated']=$date;
    $res=$db->insert('patients', $insertInfo);
    $id=$_REQUEST['id_user'];
    $where="t.users_id_user='$id' AND";
    $query="SELECT t.device_id,t.platforms_id_platform as id_platform FROM tokens as t WHERE $where t.device_id!=''";
    $resultTokens=$db->select($query);
    if($resultTokens)
    {
        include_once 'Gcm.php';
        include_once 'Apns.php';
        $deviceTokens=array();
        $deviceTokens1=array();
        $alert='Your appointment is confirmed on '.$insertInfo['date'].' at '.$insertInfo['time'];
        foreach($resultTokens as $token)
        {
            if($token['id_platform']=='1'&&$token['device_id']!='')
                $deviceTokens[]=$token['device_id'];
            if($token['id_platform']=='2'&&$token['device_id']!='')
                $deviceTokens1[]=$token['device_id'];
        }
        if(count($deviceTokens)>0)
        {
            $apns=new Apns();
            $apns->apnsPush($deviceTokens,$alert);
        }
        if(count($deviceTokens1)>0)
        {
            $gcm = new GCM();
            $message = array("m" => $alert);
            $result = $gcm->send_notification($deviceTokens1,$message);
        }
    }
    header("Location:appointments.php?m=a");
} 
$query="SELECT * FROM users";
$resultUsers=$db->select($query);



//$query="SELECT * FROM services";
$query="select * from photos where type='service'";
$resultUsers1=$db->select($query);
include_once 'header.php';

?>
  <script type="text/javascript" src="js/jquery.timepicker.js"></script>
  <link rel="stylesheet" type="text/css" href="js/jquery.timepicker.css" />
<script>
                $(function() {
                    $('#basicExample').timepicker();
                });
            </script>
<!-- Sidebar begins -->
<div id="sidebar">

    <!-- Left Main menu begins -->
        <?php include_once 'menu.php'; ?>
    <!-- Left Main menu ends -->


    <!-- Secondary nav --> 
    <div class="secNav">
        <div class="secWrapper">
            <!--div class="secTop">
            </div-->

            <!-- Tabs container -->
            <div id="tab-container" class="tab-container">
            <div id="general">

                    <!-- Sidebar big buttons -->
                     <div id="general" style="display: block;" class="active">
                      <ul class="subNav">
                        <li class="activeli"><a href="add_appointment.php" title="" class="this"><span class="icos-images2"></span>Add Appointment</a></li>
                        <li><a href="appointments.php" title=""><span class="icos-images2"></span>View/Add Appointments</a></li>
                        <li><a href="appointments_history.php" title=""><span class="icos-images2"></span>Appointments History</a></li>
                        <li><a href="reminder_settings.php" title=""><span class="icos-images2"></span>View/Add Reminder Settings</a></li>
                        <li><a href="add_reminder_settings.php" title=""><span class="icos-images2"></span>Add Reminder Settings</a></li>
                        <li><a href="medicine_reminder_settings.php" title=""><span class="icos-images2"></span>View/Add Medicine Reminder Settings</a></li>
                        <li><a href="add_medicine_reminder_settings.php" title=""><span class="icos-images2"></span>Add Medicine Reminder Settings</a></li>
                    </ul>
                </div>   
                </div>                

            </div>


       </div> 
       <div class="clear"></div>
   </div>
</div>
<!-- Sidebar ends -->


<!-- Content begins -->
<div id="content">
    <div class="contentTop">
        <span class="pageTitle"><span class="icon-screen"></span>Add Appointment</span>
        <div class="clear"></div>
    </div>

    <!-- Breadcrumbs line -->
    <div class="breadLine">
        <div class="bc">
            <ul id="breadcrumbs" class="breadcrumbs">
                <li><a href="#">Dashboard</a></li>
                <li><a href="appointments.php">Appointments</a></li>
                <li class="current"><a href="#" title="">Add Appointment</a></li>
            </ul>
        </div>

    </div>
    <!-- Main content -->
    <div class="wrapper">


        <div class="fluid">
            <form name="formAddAppointment" id="usualValidate" class="main" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST" enctype="multipart/form-data">
                <div class="widget grid6 chartWrapper" style="width:100%;min-height:680px;">
                    <div class="whead"><h6>Add Appointment Information</h6><div class="clear"></div></div>
                    <div class="formRow">
                        <div class="grid3"><label>File No:<span class="req">*</span></label></div>
                        <div class="grid9 searchDrop"><select data-placeholder="Choose a File No..." class="select" style="width: 100%" name="id_user"> 
                                <option value='0'>All</option>
                            <?php if($resultUsers && count($resultUsers)>0)
                                foreach($resultUsers as $user)
                                {?>                
                                <option value="<?php echo $user['id_user']?>"><?php echo $user['fileno']?></option>
                            <?php }?>
                            </select></div>
                        <div class="clear"></div>
                    </div>
                    <div class="formRow">
                        <div class="grid3"><label>Name:<span class="req">*</span></label></div>
                        <div class="grid9"><input type="text" class="required" name="name" id="name"/></div>
                        <div class="clear"></div>
                    </div>
                    <div class="formRow">
                        <div class="grid3"><label>Email:</label></div>
                        <div class="grid9"><input type="text" class="email" name="email" id="email"/></div>
                        <div class="clear"></div>
                    </div>
                    <div class="formRow">
                        <div class="grid3"><label>Age:</label></div>
                        <div class="grid9"><input type="text" class="required" name="age" id="age"/></div>
                        <div class="clear"></div>
                    </div>



                    <div class="formRow">
                        <div class="grid3"><label>Sex:</label></div>
                        <div class="grid9 check"><label for="solve" class="mr20">Male:</label><input style="margin-top:5px;" type="radio" id="solve"  name="act" value="m" class="required"/><label for="solve1"  class="mr20">Female:</label><input style="margin-top:5px;" type="radio" id="solve1"  name="act" value="f" /></div>
                        <div class="clear"></div>
                    </div>        

                   <div class="formRow">
                        <div class="grid3"><label>Service:<span class="req">*</span></label></div>
                        <div class="grid9 searchDrop"><select data-placeholder="select service..." class="select" style="width: 100%" name="id_service"> 
                                <option value='0'>All</option>
                            <?php if($resultUsers1 && count($resultUsers1)>0)
                                foreach($resultUsers1 as $user)
                                {?>                
                                <option value="<?php echo $user['id_photo']?>"><?php echo $user['title']?></option>
                            <?php }?>
                            </select></div>
                        <div class="clear"></div>
                    </div>

                    <div class="formRow">
                        <div class="grid3"><label>Phone:</label></div>
                        <div class="grid9"><input type="text" name="phone" id="phone" /></div>
                        <div class="clear"></div>
                    </div>
                    <div class="formRow">
                        <div class="grid3"><label>Date:</label></div>
                        <div class="grid9"><input type="text" class="required datepicker" name="date" id="date" value="<?php echo date('d-m-Y',strtotime('now'));?>"/></div>
                        <div class="clear"></div>
                    </div>
                    <div class="formRow">
                        <div class="grid3"><label>Time:</label></div>
                        <div class="grid9 searchDrop">
                           <input id="basicExample" type="text" class="time" style="width:80px" name="time"/>
                        </div>
                        <div class="clear"></div>
                    </div>
                    <input type="hidden" value="addPatient" name="requesttype"/>
                    <div class="formRow">

                        <div class="formSubmit">

                            <input class="buttonM bRed" id="next1" value="Save" type="submit">
                            <div class="clear"></div>
                        </div>     <div class="clear"></div>                   
                    </div>
                    <div class="clear"></div></div>

            </form>
       </div>

    </div>
    <!-- Main content ends -->

</div>
<!-- Content ends -->

</body>
</html>

1 个答案:

答案 0 :(得分:0)

找到此代码<?php if($user['id_photo']==$user['title']) { ?>。编辑时,应使用选项值检查数据库值。替换为<?php if($user['id_photo']==$resultPatient[0]['id_photo']) { ?>并检查。