mySQL was doing fine until mySQLi was created :/
I’ve used mysql_fetch_array() before. However, when I use mysqli_fetch_array() {Notice “i”}, there is a problem getting results from an ASSOCIATIVE array when selecting from multiple tables. That is,
$query = "SELECT t1.id, t2.id FROM t1, t2 WHERE ...";
$result = mysqli_query($conn,$query);
//if num of rows check...
while($row = mysqli_fetch_array($result))
{ $first_id = $row['t1.id']; $second_id = $row['t2.id']; }
And, I’d get an error: Undefined index: t1.id (or t2.id).
Queries work fine if I was only selecting from t1 or t2 (not both) or if I was saying $row[‘id’]; instead of $row[‘t1.id’]; but then that doesn’t help in getting different fields from two tables with identical names
Please help.
Thanks! =)
Your code has problems separating t1.id and t2.id, the result will return them both as ‘id’.
Try renaming/aliasing the column(s) using
ASin the query instead;