PHP retrieve device list for a certain user MySQL Query (EXAMPLE)

jaimzj9 years ago

You want a list of devices, that a user has been assigned? use the following example to get the details in php. (Based on the version of traccar you use, ensure to change table names)


//userId
$UID='3' 

$sqlq=mysql_query("SELECT * FROM user_device JOIN device ON device.id=user_device.deviceId WHERE userId='$UID'");

// Iterate through the rows, printing deviceId seperated by |

while ($result =mysql_fetch_array($sqlq)){

echo result['deviceId'];
echo ' | ';

}
smsoousa3 years ago

Hello Friend! How would it look for tables using tc_. Thanks

smsoousa3 years ago

I would like to show the devices attached to a user, however, defining it by name or email and not by ID