Jump to content

Priority Issue


imi_99

Recommended Posts

Hello everyone,

 

I am stuck in dealing with a new function never used before.

I will explain here what i needed.

 

I have items stored in databases with column "priority".

 

In priority column numbers can be 1,2, 3, 4, 5 .....

 

Items shows on web page according to this priority.

 

What my objective is write a script in which i can change priority in admin section.

 

e.g if i want to show item no. 5 on number 2 then how i can swap the place and update the prioriteis.

Also what if by mistake there are some values repeated, how can i make them unique.

 

thanks

Link to comment
https://forums.phpfreaks.com/topic/92905-priority-issue/
Share on other sites

$query = ("SELECT fields FROM table [WHERE field = 'value'] ORDER BY field [DESC or ASC] [liMIT #from, #to ]")

 

items in [] are optional (but remove the [] of you chose to use them)

 

DESC = orders descending

ASC  = orders asending

 

LIMIT limits the results #from (0 would be first result) #to (Last result)

 

Link to comment
https://forums.phpfreaks.com/topic/92905-priority-issue/#findComment-476840
Share on other sites

My question is different. I dont have any issue in displaying result in ascending or descending order.

 

Suppose I have items showing on website in ascending order. Sometime I have to change the priority display  like move item no.3 to no.10.

On that reason i created a table with two fields, item_column, priority_column. Items are showing according  to what is stored in priority column.

Priority column store values like 1,2,3,4...

Now there are two issue in priority column. If i want to swap position for item3 to position 7(in priority column) etc.

And if by error there are duplicates entires than how will i delete duplicate numbers from priority column.

How can overcome such kind of issues.

 

Link to comment
https://forums.phpfreaks.com/topic/92905-priority-issue/#findComment-477178
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.