Jump to content

Recommended Posts

hi, im trying to use the DISTINCT mysql command to select unique ip's that have visited my site, but im also trying to get the rest of the rows data aswell so i can output the date and time that they visited. i ran into the problem that i can output the ip but no date and time. but if i add the the 'date' in the query line i dont get a unique output as i believe the it looks for a DISTINCT ip and date then. i have the code below to help you understand a bit more. but could some please help me as i can get the right output.

 

thanks.

 

$unique_query = mysql_query("SELECT DISTINCT ip, date FROM ip ORDER BY date DESC LIMIT 10");
while($uniquerow = mysql_fetch_array($unique_query)){
    
    echo "<table width='100%' border='0' align='center'>
            <tr>
                <td width='50%' align='center' valign='middle' class='aboutme'>".$uniquerow['ip']."</td>
                <td width='50%' align='center' valign='middle' class='aboutme'>".$uniquerow['date']."</td>
            </tr>
         </table>";
}

 

this is the output atm.

 

query.jpg

Link to comment
https://forums.phpfreaks.com/topic/242405-distinct-query/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.