Well if you *know* your query only returns one row or you are just 
interessed in the first row, just forget about the while construction

$result = mysql_query("SELECT id FROM ma_users WHERE user='$PHP_AUTH_USER'");
$id=mysql_fetch_row($result)
print $id;

Good luck

René


John Wulff wrote:

>Didn't work, but its a great place for me to start from.
>As far as the difference between a looping query and a non looping query,
>i understand the difference but not exactly how to go about writing a non
>looping query.  This bit of code is looping, and i assume it dosen't need
>to be, how do i fix this?
>$result = mysql_query("SELECT id FROM ma_users where user='$PHP_AUTH_USER'");
>while(list($id) = mysql_fetch_row($result))
>{
>print($id);
>}
>
>  
>
>>hmm... seems a MySQL topic.
>>I suppose that your table is filled with correct data at some other
>>point. So what you need is a count query that returns
>>*one* result and not all records in that table. You do not want a
>>*while* loop in your PHP script, because that would show a list of
>>unique ips. So my gues would be:
>>
>>$result = mysql_query("SELECT COUNT(DISTINCT IP) AS ips FROM
>>ma_counter"); $ips = mysql_fetch_row($result);
>>pintf("Visitors = %d",$ips);
>>
>>Disclaimer: code not tested. You might want to check the MySQL manual
>>for syntax details of the query.
>>
>>Good luck
>>
>>René
>>
>>
>>John Wulff wrote:
>>
>>    
>>
>>>You're a savior, don't know how i missed that.  Thanks a bunch.  Now,
>>>one more quick question if you don't mind.  I've got this query at the
>>>bottom of my page for the purpose of a counter.  But naturally i don't
>>>want a list of all the ips logged, i just want a count of how many
>>>unique ips there are in the table.  How do i go about this?<?php
>>>$result = mysql_query("SELECT distinct ip from ma_counter");
>>>while(list($ip) = mysql_fetch_row($result))
>>>{
>>>print ("$ip");
>>>}
>>>?>
>>>
>>>
>>>
>>>
>>>      
>>>
>>>><snip>
>>>>
>>>>
>>>>
>>>>        
>>>>
>>>>>                   $mode = "entrance";
>>>>>                   if ($mode == "entrance") {
>>>>>
>>>>>
>>>>>
>>>>>          
>>>>>
>>>></snip>
>>>>I suppose you added the first line ($mode = "entrance"; ) for testing
>>>>purposes during debugging, but in order for the script to work you
>>>>should now remove it, because now $mode will always have the value
>>>>"entrance"
>>>>
>>>>good luck
>>>>
>>>>
>>>>René
>>>>
>>>>
>>>>        
>>>>
>>>
>>>
>>>      
>>>
>
>
>
>  
>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to