ID:               26411
 Updated by:       [EMAIL PROTECTED]
 Reported By:      php at bellytime dot com
 Status:           Feedback
 Bug Type:         Feature/Change Request
-Operating System: FreeBSD
+Operating System: *
-PHP Version:      Irrelevant
+PHP Version:      *
 New Comment:

Read again. Your code would always print 'No results found' while the
intended change wouldn't.


Previous Comments:
------------------------------------------------------------------------

[2003-11-25 19:16:51] [EMAIL PROTECTED]

Can you give a better example to support your request? Your example can
easily be written as:

while ($row = mysql_fetch_assoc($result)) {
   print 'Here is a result';
   ...
} 

if (!row) {
   print 'No results found';
}

I don't think that this one test is so expensive that it makes it worth
the trouble (and cost) to clutter up the language.

------------------------------------------------------------------------

[2003-11-25 12:28:30] php at bellytime dot com

Description:
------------
How about a while...else structure. Often we do 

if (!mysql_num_rows($result)) {
   print 'No results found';
}
while ($row = mysql_fetch_assoc($result)) {
   print 'Here is a result';
   ...
}

Wouldn't it be nicer to do a 

while ($row = mysql_fetch_assoc($result)) {
   print 'Here is a result';
   ...
} else {
   print 'No results found';
}




------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=26411&edit=1

Reply via email to