In Sat, Oct 15, 2011 at 7:57 PM, Stephen <> wrote:
> I am building a site for my photography.


> The photographs are displayed by category.
> The category table has a field for "order"
> In my control panel I want to be able to change the order of the categories
> by changing the values in the category field.
> I can dynamically build a form of all categories and have a field for new
> order number,  Then loop through the POST and update the values.
> The field is not unique, so I am not worried about DB errors.
> But I wonder if there is a better way.
> Thoughts please?

I'm not 100% sure I understand what you're trying to do here, but it
seems like a custom sort based on the list of categories is the order
of the day?

What is sounds like you're attempting to do is what is similar to the
netflix queue ordering, if you're famliar with that -- basically
something like this in your form page for each category:

<label for="category_one">Category One</label>
<input type="text" name="category_one" value="(current sort order for
category one)" id="category_one" />

Then the user sets the category sort order by via the input boxes.

That seems pretty straight forward.

The advanced class will do this with drag-and-drop interactive widget.

The hairy part come when you snag the photo info from the database
getting the ordering right there. I don't know if there's a way to do
that in a single query or not, I'm guessing resorting to a stored
procedure may be your best bet here, perhaps with generating a
temporary table on the fly.

PHP General Mailing List (
To unsubscribe, visit:

Reply via email to