douci1196 2015-08-20 15:38
浏览 25

更新值并在现有选择选项上显示值

first,I have table display from database, in each row it has update button. second, i have a four (4) collapsible select option form. third, the select option form has value from database. this value is also present in the column on the table above(first).

Now what i want is when i update the value from the row on the table, the collapsible form will open then the value from the table will display on the select option form. Here's my code. the code below cant open the collapsible form and display the value on the select option form.

displaytable.php

<?php
$output='';
$noresult='';                                       

if (isset($_POST['search'])) 
{
$globalpid = $_POST['search'];
$query = mysql_query("SELECT * FROM transaction where patientid ='$globalpid' order by trandate asc") or die ("could not search");
$count = mysql_num_rows($query);    

$globalpid = mysql_real_escape_string($globalpid);
if($count == '' && $countname==0)
{ 
?>
<?php require_once 'search.php'; ?>
<div class="container" style="padding-left:30px">                           
<br><p><font color="#0B3861"><?php echo "There was no search results!"; ?>  </font> 
</div>
</div> 
<?php   }else{          
?>
<?php
$total = '';
$add=mysql_query("SELECT SUM(tranamount) from transaction where patientid = $globalpid");
while($row=mysql_fetch_array($add))
{
$totalamount=$row['SUM(tranamount)'];
}
require_once 'transactionheadermenu.php';
?>
<div class="container" style="padding-top:0px; padding-left:30px; padding-right:30px;">
<div class="panel panel-default">
<div class="panel-heading"><h3 class="panel-title"><font color="#2B547E"><?php echo "$outputname";?></font></h3></div>
<div class="panel-body">
<?php require_once 'billpatientquery.php';?>
<?php
echo "<table class='table table-hover';>
<tr>
<td style='border:1px solid; color:gray' width='145px' align='center'>Patient ID</td>
<td style='border:1px solid; color:gray' width='145px' align='center'>Date</td>
<td style='border:1px solid; color:gray' width='600px' align='center'>Item / Description</td>
<td style='border:1px solid; color:gray' width='90px' align='center'>Quantity</td>
<td style='border:1px solid; color:gray' width='90px' align='center'>Price</td>
<td style='border:1px solid; color:gray' width='150px' align='center'>Amount</td>
<td style='border:1px solid; color:gray' width='30px' align='center'>Update</td>
<td style='border:1px solid; color:gray' width='30px' align='center'>Delete</td>

</tr>";
while($row = mysql_fetch_array($query)) 
{
echo "
<tr>
<td style='border:1px solid; color:gray' width='145px' align='center'>".$row['patientid']."</td>
<td style='border:1px solid; color:gray' width='145px' align='center'>".$row['trandate']."</td>
<td style='border:1px solid; color:gray' width='600px'>".$row['trandescription']."</td>
<td style='border:1px solid; color:gray' width='90px' align='center'>".$row['tranquantity']."</td>
<td style='border:1px solid; color:gray' width='90px' align='right'>".number_format($row['tranunitprice'],2)."</td>
<td style='border:1px solid; color:gray' width='150px' align='right'>".number_format($row['tranamount'],2)."</td>
<td style='border:1px solid; color:gray'><a href='updatebillindex.php?update=$row[id]'>update</a></td>
<td style='border:1px solid; color:gray'><button class='btn btn-default btn-sm';><a href='updatebillindex.php?update=$row[0]'>edit
 <span class='glyphicon glyphicon-trash'></span></a></button></td>
</tr> ";
}
echo "</table>";    
?>  
</div>

</div>
</div>
<?php   }
} ?>

updatebillindex.php

?php
        if (isset($_GET['update'])) 
        //              
        {
        $id = $_GET['update'];
        //      //$tranid = $_POST['update'];
        //$patientid = $_POST['update'];
        //$trandate = $_POST['update'];
        //$getname = $_POST['update'];
        $query = mysql_query("SELECT * FROM transaction where id = '$id'") or die ("could not search");
        $count = mysql_num_rows($query);    

        while ($rows = mysql_fetch_array($query)) {

        $id = $rows['id'];
        $tranid = $rows['tranid'];
        $trandate = $rows['trandate'];
        $patientid = $rows['patientid'];
        $transactiontype = $rows['transactiontype'];
        $trandescription = $rows['trandescription'];
        $tranquantity = $rows['tranquantity'];
        $tranunitprice = $rows['tranunitprice'];
        $tranamount =$rows['tranamount'];
        $gettrandescription = $rows['trandescription'];

        }
        }

        if (isset($_POST['selectmedicine'])) {

        $gettrandescription=$_POST['medicineid'];   
        }

        if (isset($_POST['selectroomquantity'])) {

        $tranquantity=$_POST['quantity'];
        }

        ?>
        <script type="text/javascript">
        $('#collapseone').collapseone({
        toggle: true
        });
        </script>
        <option value="<?php echo $trandescription; ?>" <?php if($trandescription==$gettrandescription){ echo "selected";} ?> ><?php echo $gettrandescription; ?></option>
        <option value="<?php echo $tranquantity; ?>" <?php if($tranquantity==$tranquantity){ echo "selected";} ?> ><?php echo $tranquantity; ?></option>

        <form action="billindex.php" method="POST">

        <input type="hidden" name="id" value="<?php echo "$id"; ?>">
        <input type="hidden" name="tranid" value="<?php echo "$tranid"; ?>">
        <input type="hidden" name="patientid" value="<?php echo "$patientid"; ?>">
        <input type="hidden" name="trandate" value="<?php echo "$trandate"; ?>">
        <input type="hidden" name="transactiontype" value="<?php echo "$transactiontype"; ?>">
        <input type="hidden" name="trandescription" value="<?php echo "$trandescription"; ?>">
        <input type="hidden" name="tranquanity" value="<?php echo "$tranquantity"; ?>">
        <input type="hidden" name="tranunitprice" value="<?php echo "$tranunitprice"; ?>">
        <input type="hidden" name="tranamount" value="<?php echo "$tranamount"; ?>">
        <input type="submit" name="update" value="Update">

        </form>

  <div class="panel panel-default">
        <div class="panel-heading" role="tab" id="headingTwo">
        <h4 class="panel-title">
        <a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseTwo" aria-expanded="false" aria-controls="collapseTwo">
        Medicine
        </a>
        </h4>
        </div>
        <div id="collapseTwo" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingTwo">
        <div class="panel-body">
        <form action="transaction.php" method="POST">
        <div class="col-md-6">
        <div class="panel panel-info">
        <div class="panel-heading"><h7>Medicine Type : </h7></div>
        <div class="panel-body">
        <select name="selectmedicine" class="form-control col-sm-4" id="medicinename">
        <option id="0" style="width:100px"></option>
        <?php

        $medicine = mysql_query("SELECT * FROM medicine");
        while ($row = mysql_fetch_array($medicine)) {
        echo '<option id="' . $row['medicinename']  . '"';
        echo ' value="' . $row['medicineid'] . '"';
        if($row['medicineid'] == $row['medicinename']) {
        echo ' selected="selected"'; 
        }
        echo '>';
        echo $row['medicinename'];
        echo '</option>';               
        }
        ?>
        </select>
        </div>
        </div>
        </div>          

        <div class="col-md-6">
        <div class="panel panel-info">
        <div class="panel-heading panel-height:20px":><h7>Quantity : </h7></div>
        <div class="panel-body">
        <select name="selectmedicinequantity" class="form-control col-md-4" id="quantityname">
        <option id="0" style="width:100px"></option>

        <?php

        $medicinequantity = mysql_query("SELECT * FROM quantity");
        while ($displayquantity = mysql_fetch_array($medicinequantity)) {
        $quantityid = $displayquantity['id'];
        $quantityname = $displayquantity['quantityname'];
        //$quantityprice = $displayquantity['quantityprice'];
        ?>

        <option id=" <?php echo $displayquantity['quantityid']; ?>"><?php if($displayquantity['quantityid'] == $displayquantity['quantityname']) echo 'selected="selected"'; ?><?php echo $displayquantity['quantityname'] ?></option>

        <?php 
        }
        ?>

        </select>
        </div>
        </div>
        </div>  
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
    • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
    • ¥16 mybatis的代理对象无法通过@Autowired装填
    • ¥15 可见光定位matlab仿真
    • ¥15 arduino 四自由度机械臂
    • ¥15 wordpress 产品图片 GIF 没法显示
    • ¥15 求三国群英传pl国战时间的修改方法
    • ¥15 matlab代码代写,需写出详细代码,代价私
    • ¥15 ROS系统搭建请教(跨境电商用途)
    • ¥15 AIC3204的示例代码有吗,想用AIC3204测量血氧,找不到相关的代码。