Hi there. How can I tell the below to not print the very last comma after $line[id] if it is the last record of the loop? while($line= mysql_fetch_array($getresult, MYSQL_ASSOC)){ print "[\"$line[lastName] $line[firstName]\",\"$line[id]\"],"; }
Hehe,
swap it around:
$i=0; while($line= mysql_fetch_array($getresult, MYSQL_ASSOC)) { if($i<>0) { echo ", "; } else { $i = 1; } print "[\"$line[lastName] $line[firstName]\",\"$line[id]\"]"; }
I always just add the comma, and use substr to strip it off after the loop.