I'm trying to add a column from an other table to a while loop from an other table, and I tried something like this but doesn't seems to work. How can I achieve something like this? As far as I understand I need to save the variables from data_auth in a array but how do I echo them withing the loop ?
$SQL = mysql_query("SELECT * FROM users ORDER BY data_reg DESC LIMIT $offset, $rowsperpage");
while($rand = mysql_fetch_assoc($SQL)){
$id = $rand['id'];
$user= $rand['user'];
$SQL2 = mysql_query("SELECT data_auth FROM access_log WHERE user = '$user'");
while($rand = mysql_fetch_assoc($SQL2)){
$data_auth = $rand['data_auth'];
}
?>
<li><?php echo "$user"; ?></li>
<li><?php echo "$data_auth"; ?></li>
<?php
}
?>