tanisha s tanisha s - 1 year ago 76
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>";


Answer Source

Try to use this code

$query = "
     , q.id AS qid,
       q.id AS id
  FROM questions q
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download