PDA

View Full Version : PHP + MySQL programming help needed; a call to programmers abroad!


Outsider
Feb 21st, 2008, 10:29 AM
I'm in the middle of writing a web application in php, which uses a mysql database as the back end.
Anyway, I'm working on an interface to display a list of items. The list allows for the order of the items to be customized, so I've placed UP and DOWN arrow icons beside each line to allow the row to be moved up and down within the list.

The first row only gets a DOWN arrow (since it can't be moved any higher on the list) and the last row should only get a UP arrow (since it can't be moved any lower on the list).

What I don't know how to do is detect the last row displayed, so it only displays one arrow.

Any ideas on how to accomplish this?

Silver Bullet
Feb 21st, 2008, 10:37 AM
Maybe use a "id" field with a number so you can use that as the ordering field. Then just update the db as need based on the arrow movements. Going to be a rather annoying sql update statement .. but it's possible.

Tereno
Feb 21st, 2008, 10:52 AM
How about checking the length of the list? Or checking for null for next item's in the list?

Outsider
Feb 21st, 2008, 10:55 AM
I am currently using a 'sort_order' field to sort by.
And the arrows just change the values in that column.

Is there a way of finding out how many items an sql query returns?

Silver Bullet
Feb 21st, 2008, 10:59 AM
there is a "count" command... link (http://www.techonthenet.com/sql/count.php)

Evil Baby
Feb 21st, 2008, 12:48 PM
there is a "count" command... link (http://www.techonthenet.com/sql/count.php)

or just use mysql_num_rows on your resutl string.

http://ca3.php.net/mysql_num_rows