Ok say im storing a IP log, and each row stores..
Members ID :: IP Number
Now I want to list the members IP address and the count of users that also used that IP address.
So basically how would I make this code, 1 query.
$wQ = $db->Query('SELECT ip FROM ipLog WHERE mid=\''.$mid.'\'');
while($wR = $db->Fetch($wQ))
{
?>
<tr align="center" bgcolor="#FFFFFF">
<td><a href="http://leapcash.com/admin/members.php?search=<?=$wR['ip']?>&by=ipLog&status=<?=$view?>" target="_blank"><?=$wR['ip']?></a></td>
<td><?=$db->QQuery('SELECT COUNT(*) FROM ipLog WHERE ip=\''.$wR['ip'].'\'')?></td>
</tr>
<?
}
Please just focus on the two queries.. There has to be a way to make it just one.
Query 1:
SELECT ip FROM ipLog WHERE mid='idnum'
After getting their ips.. lets loop through their ips and count all other users that match
Query 2:
SELECT COUNT(*) FROM ipLog WHERE ip='userip'
So how would I go about combining these two.. because if someone used a proxy and logged on 150 IP's it would take a long time to load 151 quieries.