rich11 Posted February 15, 2008 Share Posted February 15, 2008 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 More sharing options...
rhodesa Posted February 15, 2008 Share Posted February 15, 2008 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 https://forums.phpfreaks.com/topic/91303-div-layers-and-php-and-databases/#findComment-467930 Share on other sites More sharing options...
Dragen Posted February 15, 2008 Share Posted February 15, 2008 for something small and simple like this, I'd go with rhodesa's option 3. Then you can easily use css to hide and display all of the divs. No javascript or page reloads would be neccessary. Link to comment https://forums.phpfreaks.com/topic/91303-div-layers-and-php-and-databases/#findComment-467933 Share on other sites More sharing options...
rhodesa Posted February 15, 2008 Share Posted February 15, 2008 Option 3 would require some very very minimal javascript do you have any code written so far you can share? Link to comment https://forums.phpfreaks.com/topic/91303-div-layers-and-php-and-databases/#findComment-467938 Share on other sites More sharing options...
Dragen Posted February 15, 2008 Share Posted February 15, 2008 hmm.. yeah. It's possible in all css, but after quickly trying it, I realise that it would probably be easier with a quick javascript snippet. Link to comment https://forums.phpfreaks.com/topic/91303-div-layers-and-php-and-databases/#findComment-467963 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.