我正在尝试存储内部连接两个表的列中的值。不确定我的逻辑是否正确。截至目前,在选择option
的下拉列表中, value
会存储到会话变量中,该变量将返回 NULL 。这是我打印结果的查询:
$query =
"
SELECT c.emp_id
, c.client_contact_id
, c.project_id
, p.project_id
, p.project_codename
FROM tlive_project_clist c
JOIN tlive_project p
ON p.project_id = c.project_id
ORDER
BY p.project_codename
";
echo <select name="Projects">;
$result = mysqli_query($con, $query) or die("Query error: " . mysqli_error($con));
while ($row = mysqli_fetch_array($result)){
echo '<option value="'.$row['project_id'].'">'.$row['project_codename'].'</option>';
}
echo </select>;
php验证:
<?php
session_start();
require_once('php/config.php');
$project_id = $_POST['Projects'];
if(empty($project_id)){
echo '*Please select a project';
}
else{
$_SESSION['PROJECT_ID'] = $project_id;
}
?>