【发布时间】:2018-07-26 22:42:04
【问题描述】:
我仍在学习 PHP,我正在尝试使用下拉菜单向数据库中插入新值。到目前为止,这是我所做的:
<table class="table">
<tr>
<th>Employee Name</th>
<th>Time</th>
<th>Priority</th>
<th>Assignee</th>
<th>Subject</th>
<th>Problem</th>
<th>Status</th>
</tr>
<?php
include ('database.php');
$result = $database->prepare ("SELECT * FROM tickets order by ticketno DESC");
$result ->execute();
for ($count=0; $row_message = $result ->fetch(); $count++){
?>
<tr>
<td><?php echo $row_message['full_name']; ?></td>
<td><?php echo $row_message['time']; ?></td>
<td><?php echo $row_message['priority']; ?></td>
<?php if ($row_message['assignee']) : ?>
<td><?php echo $row_message['assignee']; ?></td>
<?php else : ?>
<td>
<form method="post" action="update1.php">
<input type="hidden" name="ticketno" value="<?php echo $row_message['ticketno']; ?>" />
<input type="submit" name="accept" value="Accept"></input>
</form>
</td>
<?php endif ; ?>
<td><?php echo $row_message['subject']; ?></td>
<td><?php echo $row_message['problem']; ?></td>
<td>
<label for=""></label> <select style="font-family: Questrial;" name="status" required>
<option disabled selected hidden>Select Status</option>
<option name="status" value="In Progress">In Progress</option>
<option name="status" value="Closed: Cancelled">Closed: Cancelled</option>
<option name="status" value="Closed: Solved">Closed: Solved</option>
</select>
</td>
</tr>
<?php } ?>
</table>
我还有一个示例脚本:
<script>
$(document).ready(function(){
$('input[type="radio"]').click(function(){
var gender = $(this).val();
$.ajax({
url:"insert.php",
method:"POST",
data:{gender:gender},
success: function(data){
$('#result').html(data);
}
});
});
});
</script>
我担心的是,如果我使用下拉菜单,我不确定我的 ('input[type="radio"]') 应该是什么。
这是我的表架构:
表架构
【问题讨论】:
-
试试
option[name="status"]看看是否可行。 -
@Syfer 好的,我会试试的,我会告诉你的。
-
@Syfer 没用 :(
标签: php html mysql database phpmyadmin