Jump to content

Ordering


gple

Recommended Posts

I have a list of documents in which the name gets outputted onto a website. I created another column in the table to distinguish which order they should appear in. so I have 10 records and each of them has a different number next to it (1-10) and this will be the order that they appear in. How can I make sure that the user does not put the same number for two different records?

 

 

Link to comment
Share on other sites

There should be a better way, but heres a soultion

 

<?php

$sql = "SELECT sort_number? FROM table_name";
$result = mysql_query($sql);

while($row = mysql_fetch_array($result))
{
    if($user_input == $row[0])
    {
         // We found a matching sort number!!
         die('That sort number has been taking');
    }
}

?>

 

In theory should work.

Link to comment
Share on other sites

There is no logical reason you can't allow 2 order numbers that are the same. I do it all the time. When you select the records from the DB with the sort, if they have the same number, then the older record will be first. Do you have a reason they can't use the same number?

Link to comment
Share on other sites

Yeah, store the order identifiers in an array when you use the draggable list, make a form that send post data to PHP that will then update the database sort identifiers. I've created a draggable list before that changes the sort order of pages, I can show you if you like.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.