我运行以下查询并获得结果:
现在,如果我正在运行以下操作,那么我将user_id设为0。
<?php
session_start();
require_once('connectvars.php');
$dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
$user_id = $_SESSION['user_id'];
$result = mysqli_query($dbc,"SELECT * FROM `user_question`join question WHERE user_question.qid = question.qid and user_question.user_id = $user_id")
or die("Error in fetching the value.");
while ( $row = mysqli_fetch_array($result))
{
echo 'user id : ';
echo $row['user_id'];
echo "<br>";
echo 'qid: ';
echo $row['qid'];
echo "<br>";
echo 'answer_key: ';
echo $row['answer_key'];
echo "<br>";
}
?>
我如何获得user_id:4?
答案 0 :(得分:2)
您可以按照以下方式执行此操作:
$result = mysqli_query($dbc,"SELECT user_question.user_id,user_question.qid,user_question.answer_key FROM `user_question`join question WHERE user_question.qid = question.qid and user_question.user_id = $user_id")
现在回显$ row ['user_id'] ...