tanisha s tanisha s - 6 months ago 21
HTML Question

get column with same name from multiple tables

i have two tables:
USERS(id, name, email, password)
QUESTIONS(id, userid, type, ques, date, time)

i have to pass the value of questions.id as qid.
i am unable to get the desired result with the following code. instead of taking 'id' value of QUESTIONS table, it is taking the 'id' value of USERS table, and therby producing wrong output.

$query = "
, q.id qid
FROM questions q
JOIN users u
ON u.id = q.userid
WHERE type = 'technical'
BY date
, time DESC
$result = mysqli_query($conn,$query);
while ($row = mysqli_fetch_array($result)) {

$id = $_SESSION['id'];
$user = $row['username'];

echo strtoupper($user);

echo "<a href='allview.php?qid=$row[id]' class='class4'> $ques </a>";



Try to use this code

$query = "
     , q.id AS qid,
       q.id AS id
  FROM questions q