PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I have a while loop creating a table containing all my fields this part below checks if it is the last row of the field before the while loop ends to start the next field. so basicly its just adding a check box to every row of the table
this checks if the loop count $i is the last one by checking with num_fields but i have had to take one away from the num count not sure why as i thought the last $i should be the same number as the num_field count is this someting to do with the $i starting at 0 not 1.
Anyway heres the problem this works fine but as soon as i get 5 it doesnt add the column i have no idea why
thanks reece
Last edited by reecec on Mon Oct 23, 2006 1:42 pm, edited 1 time in total.
The code you are providing is not enough for us to help you out.
Make sure you are not counting the number of rows each time the while loop iterates, just do it once outside, it shouldn't change at any point. (This is not the problem imho).
About $i and mysql_num_fields, $i is a counter that probably starts at 0 in your script, meaning, the second row will be when $i equals 1. Now, mysql_num_fields returns the number of rows, now let's say that $n is the number of rows in your result, you'll be at the last row when $i equals $n - 1.