There's a few things i would change:
if the query fails, throw an error message so you know
separate your code from your html output...keep information variables and only output html once you have gathered all of them
* $num_results will only be greater than $start when $start when $start is zero and an image is retrieved because your query has a LIMIT clause in it with the 2nd parameter of 1. You need to rethink your code a bit.
You are going to need two queries to determine if there is a NEXT button. There are two ways to do this:
1)
add 'SQL_CALC_FOUND_ROWS' after the word 'SELECT' in your query. this will cause SQL to calculate all the rows that would have been returned if there were no limit clause
run a second query: "SELECT FOUND_ROWS() as total_rows"
when you mysql_fetch_array the results of that query, total_rows will tell you how many total pics you have.
2) run your first query normally then run a query to simply count all the image records where A_P_ID = whatever without the limit clause
If the total number of rows > ($start+1) then you have a next button. otherwise you don't.