Jump to content

DIV Layers and PHP and databases


rich11

Recommended Posts

Hello

 

I have created two div layers.  The first layer are going to be populated from a database.  10 People, and when I click on the items the will have information like office hours, phone numbers, and so on.  And I want to show a div layer with that information and then they can close the div layer or just click on another person and show that info in the div layer.  Not sure how that second div gets populated from the database??? 

 

Do I call to the database when I click on the persons name and pass the id of the person???  I am really lost on this one.

 

Rich

Link to comment
Share on other sites

You have a couple of options

 

1) No javascript: If the page was called people.php, each person would be a link to people.php?id=# where # was that person's ID number. Then, in the code for the page, you look for that id via $_GET['id']. If it exists, pull that persons information and display it in the second div. This requires the page to reload every time a persons name is clicked

 

2) Use a javascript library like Scriptaculous/jQuery that makes an ajax call to a page that will return a block of HTML about the person (like person_details.php?id=#) So, person_details.php would return a snippet of HTML that would then be put into the second div each time a person's name is clicked.

 

3) If there aren't too many people (under say...25), the easiest way in my opinion would be to draw a div for each person, with a style attribute of "display:none;". Also give each div a unique id like id="pid_#". Then, when a person's name is clicked, use javascript to first hide all the DIVs, and then show the applicable one.

 

I'm sure there are other ways, but I think these are your best three options.

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.