[英]How to add the option tag inside php table and pass the selected value to mysql db without submit button?
我創建了一個升級系統,用戶可以在其中上載.csv文件,並且可以在網頁中查看上載的詳細信息。
選項標簽將顯示在每行中,其中包含以下選項:
我只想將所選項目存儲在數據庫中,以便使用該系統的其他座席可以查看針對每個投訴發送的級別升級。
這是我的代碼。 我無法將選項項存儲在DB中。 例如:當我選擇“ *已發送第一級升級”時,它不會顯示給其他人。 請幫助
<table width="100%" border="1" cellpadding="1" cellspacing="1" style="font-size:10.5px; font-family:verdana;" > <tr> <td>Name</td> <td>SR Number</td> <td>Service Impact</td> <td>Customer Ref No</td> <td>Reported Date and Time</td> <td>Issue</td> <td>Pending Reason as per TAC</td> <td>Expected Time for Resolution</td> <td>TAC Agent</td> <td>Cx Contact</td> <td>Elapsed Time</td> <td>Archive</td> <td>Send Email</td> <td>Comment</td> </tr> <?php while ($ccs=mysqli_fetch_assoc($records)) { $A=$ccs['Name']; $B=$ccs['SRNumber']; $C=$ccs['ServiceImpact']; $D=$ccs['CustomerRefNo']; $E=$ccs['ReportedDateAndTime']; $F=$ccs['Issue']; $G=$ccs['PendingReasonAsPerTAC']; $H=$ccs['ETR']; $I=$ccs['TACAgent']; $J=$ccs['Cxcontact']; echo(" <tr class='options'> <td>$A</td> <td>$B</td> <td>$C</td> <td>$D</td> <td>$E</td> <td>$F</td> <td>$G</td> <td>$H</td> <td>$I</td> <td>$J</td> <td> "); date_default_timezone_set('Asia/Colombo'); $the_time = date('H:i'); $hours = "00"; $minutes = "00"; $seconds = "00"; $new_time=$E; $datetime1 = new DateTime($the_time); $datetime2 = new DateTime($new_time); $interval = $datetime2->diff($datetime1); $hours=$interval->format('%h'); $minutes= $interval->format('%i'); $seconds= $interval->format('%s'); echo $hours." Hours ".$minutes." Minutes ".$seconds." Seconds</br></br>"; echo(" <td><a href=Escalation_Display.php?delete=$B>Archive</a></td> <td><a href=Escalation_Display.php?ID=$B>Email</a> </td> <td> <select id='select'> <option value='1'>select</option> <option value='2'>First level Escalation sent</option> <option value='3'>SECOND</option> <option>THIRD</option> <option>CLOSURE NOT SENT</option> </select> </td> </tr> "); } ?> </table>
提前致謝
在要從中獲取記錄( $records
)的表中做一個列名Comment
。 我試過了。 我給你怎么做。 但是,如果需要,請在<select></select>
中的if條件中進行更改。
<?
.
.
while ($ccs=mysqli_fetch_assoc($records)){
$B=$ccs['SRNUMBER']; I assumed column 'id' (Primary Key and auto-incremented). Change with your column name.
$escValue=$ccs['Comment']; I assumed column 'escalation_value' as i wrote above.
.
.
.
?><td>
<select id='selectEscalation'>
<option hidden>Select</option>
if($escValue != 1) {
<option value="1."-".$B;">First level Escalation sent</option>
}
if($escValue != 2 && $escValue == 1) {
<option value="2 . "-" . $B;">Second level Escalation sent</option>
}
if($escValue != 3 && $escValue==2) {
<option value="3."-".$B;">Third level Escalation sent</option>
}
if($escValue == 3) {
<option>CLOSURE NOT SENT</option>
}
</select>
</td>
</tr>");
}
?>
</table>
<script>
$('#selectEscalation').change(function(){
var EscalationValue=$('#selectEscalation').val();
$.ajax({url:"Ajax-submitEscalation.php?EscalationValue="+EscalationValue,cache:false,success:function(result){
alert("Escalation Sent");
}});
});
</script>
Ajax的submitEscalation.php
<?
// split the contents of $_POST['data'] on a hyphen, returning at most two items
list($data_value, $data_id) = explode("-", $_POST['EscalationValue'], 2);
//escalation_value column name as i wrote above.
$Query="UPDATE TableName SET Comment='$data_value' WHERE SRNUMBER='$data_id'"
?>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.