IF inside LOOP?

From: Date: Mon, 15 Jul 2002 02:04:22 +0000
Subject: IF inside LOOP?
Groups: php.general 
Request: Send a blank email to php-general+get-107653@lists.php.net to get a copy of this message
Hi all. I’ve been fooling around with a LOOP which should show one or more text string stored in separate rows in a DB. The trick would we to separate them with commas (,) when there’s another string to show or end it with a period (.) if no other row is found according to the SELECT criteria. This is what I have so far: for ($m=0; $m<$num_rows2; $m++) { $row2 = mysql_fetch_array($result2); echo $row2[devlanguage]; if ($m < $num_rows2) { echo ", "; } else { echo "."; } } The problem is that the LOOP stops as it’s told to do, keeping the ELSE statement from doing it’s work, resulting in comma separated string as it should, but also add an extra comma at the end of it instead of a period. What approach should I use? Thanks in advance, <mailto:webmaster@icaam.com.ar> Cesar Aracena CE / MCSE+I Neuquen, Argentina +54.299.6356688 +54.299.4466621

« previous php.general (#107653) next »