php - apply code to all looped items but last one -
I looping through some mysql results and Do I have to calculate rows and then use a counter and an if / else statement? Or is there any easy way? Try something like this: Not very short, but it must do the trick. Alternatively, you can do what you suggested: All the best, Fabian and gt; & Lt; / Span & gt; / Code> For each of those, except for the last line, what is the easiest way to do this?
$ result = mysql_query ($ Sql); $ List = array (); While ($ row = mysql_fetch_assoc ($ result)) {$ list [] = $ row; } $ LastItem = array_pop ($ list); Foreign currency ($ $ as list of items) {echo sprintf ('& lt; span id = "bottom">% s ; $ item [' value ']); } // Do something with the last item.
$ result = mysql_query ($ sql); $ Num = mysql_num_rows ($ result); For ($ i = 0; $ i & lt; $ num-1; $ i ++) {$ element = mysql_fetch_assoc ($ result); // resonate here.} $ Item = mysql_fetch_assoc ($ result); // Get the last item.
Comments
Post a Comment