Hi, When i add a new entry into my table i want to check all previous rows in the field row_order to check what is the highest numbers. Then i want to add 1 to this number and use it for the current entry in the row_order field. How would i do this? Cheers, Adam
why not just have a column that has the auto-increment on it? This makes the new row with the next highest number
make row_order auto_increment edit: if for whatever reason you don't want to do that, you could always get the highest number like this: SELECT row_order FROM table ORDER BY row_order DESC LIMIT 1
There may be a short-cut that I don't know of, but I guess you'll need to query the database to get the value that you're looking for (select row_order from tablename order by row_order desc limit 1), save that off and re-query the db to insert the new row, adding 1 to the result of the previous query for row_order. Is this what you're trying to do, or am I missing something?
why are you making confussion brothers. just use MAX(id) like $max = max id $next = $max + 1 max id should be taken from db using MAX(id) ... thanks