Jump to content

Stuck on how to easily sort items


Lostnode

Recommended Posts

I am having difficulty wrapping my head around how I can sort things easily.

Basically I have a few chunks of code which I will be extracting and making into includes to tidy up my code, but what I am looking for is a way to sort the includes by user preference.

 

For instance say I have 4 include files, incude1.php though include4.php, user 1 wants them to show up 1, 2, 3, 4, user 2 wants them to show up 1, 3, 2, 4 and user 3 wants them to show up 4, 1, 3, 2....

 

I was thinking about using if statements but that is most definitely not the right way to go.

 

The structure for this would be in the settings table, so they would set their preferences there, but I am stuck on how to get it to physically put things in the right order.  I am sorry I have no code to show as I have absolutely no idea of where to start.

 

I am looking for a push in the right direction (then I can post some code when it goes horribly wrong)

Any help would be appreciated.

Link to comment
Share on other sites

Thanks for the quick reply,

 

I will have to think about this a bit more, as my includes aren;t actually called include#.php, they are actually named...  worse come to worse, I may have to number them.

 

As for $order, I am not sure how that would work either, as I need to pull the variables from the database...

 

I will test it out tomorrow when I get to the office...

 

Could this work?

 

$order = "$var1, $var2, $var3, $var4";

 

 

Link to comment
Share on other sites

Well how is it stored in the database? And what does the data actually look like?

 

 

 

It will be stored as an integer, 1 through as many modules will be created (currently 5 but potentially more) and the variables are descriptive of the module, currently $cpord, $tnord, $dhord, $amord, $feord.  the files them selves are name based, canpar.php, tnt.php, dhl.php, aramex.php and fedex.php,

 

This is to grow of course, more includes and more order variables.

Link to comment
Share on other sites

Are the modules stored in the database? You could have the users sort them by their ID, and then just gather the modules from the database, and include them in the right order.

 

No they are not in the database, that hadn't even occurred to me to do it that way.  I will think it over and see if I can come up with a solution, I will post my code if I get into trouble with it.

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.