这就是我想要做的事情。我得到了带有数据库的 eprofile。该数据库由 2 个表组成,即个人数据和国籍。第一个用户可以查看他们的旧个人信息,然后我将为他们制作更新/编辑页面。国籍在其他表中,因为下拉菜单中的国籍。然后用户可以更改他们的个人和信息,在他们插入新信息后,他们单击提交按钮并转到 process.php,其中发生数据库更新过程。我的问题是,我不知道如何定义/或如何连接两个表,即更新查询中的个人数据和国籍。
国籍代码
<?php
$query = "SELECT nationality_type FROM nationality";
$result = mysql_query ($query); ?>
<select name="personal_nationality" >
<?php while($row = mysql_fetch_array($result)){ ?>
<option value="<?php echo $row['nationality_type']?>" <?php if ( $personal_nationality == $row['nationality_type']){ ?> selected <?php } ?>>
<?php echo $row['nationality_type']?></option>
<?php }?>
</select>
process.php 代码
<?php
$host="localhost"; // test local
$username="lasadmin"; // Mysql username
$password="lasadmin"; // Mysql password
$db_name="eprofile"; // Database name
$db = mysql_connect($host, $username, $password);
$link = mysql_select_db($db_name,$db);
$personal_designation = $_POST['personal_designation'];
$personal_department = $_POST['personal_department'];
$personal_job_grade = $_POST['personal_job_grade'];
$personal_emp_group = $_POST['personal_emp_group'];
$personal_current_company = $_POST['personal_current_company'];
$personal_work_location = $_POST['personal_work_location'];
mysql_query("UPDATE personal_data SET personal_designation = '".mysql_real_escape_string($_POST["personal_designation"])."', personal_department = '".mysql_real_escape_string($_POST["personal_department"])."', personal_job_grade = '".mysql_real_escape_string($_POST["personal_job_grade"])."', personal_emp_group = '".mysql_real_escape_string($_POST["personal_emp_group"])."', personal_current_company = '".mysql_real_escape_string($_POST["personal_current_company"])."', personal_work_location = '".mysql_real_escape_string($_POST["personal_work_location"])."' WHERE LAS_login_id = '".mysql_real_escape_string($_POST["LAS_login_id"])."'");
$personal_full_name = $_POST['personal_full_name'];
$personal_title = $_POST['personal_title'];
$personal_date_birth = $_POST['personal_date_birth'];
$personal_marital_status = $_POST['personal_marital_status'];
$personal_nationality = $_POST['nationality_type'];
mysql_query("UPDATE personal_data SET personal_full_name = '".mysql_real_escape_string($_POST["personal_full_name"])."', personal_title = '".mysql_real_escape_string($_POST["personal_title"])."', personal_date_birth = '".mysql_real_escape_string($_POST["personal_date_birth"])."', personal_marital_status = '".mysql_real_escape_string($_POST["personal_marital_status"])."', nationality_type = '".mysql_real_escape_string($_POST["personal_nationality"])."' WHERE LAS_login_id = '".mysql_real_escape_string($_POST["LAS_login_id"])."'");
?>
当我尝试更改信息(测试)时,显示此错误-注意:未定义索引:第 26 行 C:\wamp\www\eprofile\process.php 中的国籍类型
这是第 26 行的代码
$personal_nationality = $_POST['nationality_type'];
你能告诉我问题是什么,这个问题的解决方案是什么?我应该在定义的索引上做什么?