I want to match contact from both tables and fetch details of mother
in mysql using JOIN clause in php.
Table students
name | mother | mcontact |
---|---|---|
Larry | Wanda | 12345678 |
Table parents
name | parent_of | relation | contact | other |
---|---|---|---|---|
Wanda | Larry | mother | 12345678 | any other details |
And this is my code
$user_query = 'SELECT students.mcontact FROM `students` JOIN `parents` ON students.mcontact=parents.contact';
$user_result = mysqli_query($db_conn, $user_query);
while ($users = mysqli_fetch_object($user_result)){
echo $users->name}
It is showing me an error Undefined property $name
If there is any other way to do it please enlighten me.