<form action = "settings.php" method = "post">
Student ID*:
<input type = "text" name = "std_id" value = "<?php echo $user_data['std_id'];?>"><br>
Firstname*:
<input type = "text" name = "name" value = "<?php echo $user_data['name'];?>"><br>
Surname*:
<input type = "text" name = "surname" value = "<?php echo $user_data['surname'];?>"><br>
Group*:
<select name = "group" id = "group">
<option value="0"><-- Please Select Item --></option>
<?php
$show=mysql_query("SELECT * FROM room_group_options ORDER BY op_id");
while ($array = mysql_fetch_array($show))
{
$id = $array['id'];
$group = $array['group'];
echo "<option value = '$id'> $group </option>";
}?>
</select><br>
Email*:
<input type = "text" name = "email" value = "<?php echo $user_data['email'];?>"><br>
<input type = "submit" name "update" value = "update">
</form>
上面這段代碼是從數據庫中查詢的更新形式。除組列表框將MySQL中的變量值傳遞給數組
if(empty($_POST) === false && empty($error) === true)
{
$update_data = array(
'std_id' => $_POST['std_id'],
'name' => $_POST['name'],
'surname' => $_POST['surname'],
'group' => (int)$_POST['group'],
'email' => $_POST['email'],
);
print_r($_POST);
print_r($update_data);
die();
}
這是用於從提交按鈕中獲取數據。我嘗試使用print_r來獲取每個數組中的所有值。他們都有團隊。我能解決這個問題嗎?
Array ([std_id] => 52211001 [name] => testname2 [surname] => testsurname1 [group] => [email] => [email protected])
Array ([std_id] => 52211001 [name] => testname2 [surname] => testsurname1 [group] => 0 [email] => [email protected])
這是一個輸出
被取出,並在下拉框中(格式)中顯示的組名。 –
也檢查值。他們只是數字嗎? – Samson
感謝@radashk 全部解決:) –