Jump to content

Help on re-ordering a list of info.


dipp02

Recommended Posts

Hello.

 

I am creating a function for a site to show a list of companies with phone, addy, email, website, etc.. with about 10 listings that will show up on the page so some listings will be "off the screen".

 

what the client would like to have the list do so each company will have a turn at the top of the page. is when the page refreshes the company at the bottom of the list will go to the top of the list and so on.

 

 

or if anyone has any other idea on how to have each company have a turn at the top of the page...

 

i am using framework codeigniter and mysql database for the site.

 

if i wasn't clear please let me know so i can explain better.

 

 

Thanks in advance.

Link to comment
Share on other sites

One way is using sessions, like this example:

 

session_start();

if(!isset($_SESSION['list'])){
$_SESSION['list'] = array(
				"Company 1",
				"Company 2",
				"Company 3",
				"Company 4",
				"Company 5",
				"Company 6",
				"Company 7",
				"Company 8",
				"Company 9",
				"Company 10"
			);
}

$tmp = $_SESSION['list'][count($_SESSION['list']) - 1];
$list = array_pop($_SESSION['list']);
array_unshift($_SESSION['list'], $tmp);

echo "<pre>", print_r($_SESSION['list']), "</pre>";

Link to comment
Share on other sites

  • 4 months later...

How can i do this so on every computer the company thats next in line comes up on every computer not just on the computer i am on?

 

using sessions will only happen to that one computer.

so if company 1 is up and i refresh the page company 2 comes up. but on a totally different computer company 1 shows up and not company 3 which is next in line.

 

should i just use a simple for loop?

 

any ideas? i was going to make a field in the database under the company table called 'position' and add/minus the position number everything the page refreshes.

 

Any help on this would be great!

 

Thanks in advance!

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.