I have always retrieved database information using the following general 
format:

<?php
     mysql_connect($host, $user, $password);
     mysql_select_db($database);
     $query = "select * from table";
     $result = mysql_query($query);
     while ($row = mysql_fetch_assoc($result)) {
         echo $row["user_id"];
         echo $row["fullname"];
     }
     mysql_free_result($result);
?>

But sometimes I am searching for something specific, with a primary key 
as my WHERE clause.  In other words, I will only EVER get one result.  
In this case, a while loop seems to be overkill, since it will only loop 
once.

Does it seem like a bad idea to just do:

$row = mysql_fetch_assoc($result);
echo $row['user_id'];
echo $row['fullname'];

etc?  Or is there a compelling reason to use the loop?  the only reason 
I ask is because I've never seen search query code that -isn't- in a 
loop of some sort.  But it works fine the way I do it, immediately above.



Thanks,

Erik





----

Erik Price
Web Developer Temp
Media Lab, H.H. Brown
[EMAIL PROTECTED]


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

Reply via email to