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
https://forums.phpfreaks.com/topic/91303-div-layers-and-php-and-databases/
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.

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.