|
|||||||
| PHP Discussion and technical support for using and deploying PHP based websites. |
![]() |
|
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hopefully Simple Switch Question
Obviously a Newbie here. Some may recognize this script as It was graciously given to me here
I am using the switch script to change pages within a body div dynamically. My basic question is, how can i get that down to a DIV level and not on a "page" level? http://www.lunarcafe.com/tryme/template.php I am using: <div id="body1"> <?php include("inc.html"); $page = $_GET['page']; switch ($page) { case "cats"; include ("cats.html"); break; case "dogs"; include ("dogs.html"); break; } ?></div> <div id="body2"> <?php include("inc.html"); $page1 = $_GET['page']; switch ($page1) { case "mice"; include ("mice.html"); break; case "fish"; include ("fish.html"); break; } ?> If you look at my page, menu items 2-3 apply to the first DIV, and the 4-5 menu items apply to the 2nd DIV. When I hit 4-5, the information in DIV 1 goes away and the proper files appear in Div2. My menu is structured like this <?php $home = $_SERVER["PHP_SELF"]; echo "<a href=\"$home\">Home</a><br />"; echo "<a href='http://www.lunarcafe.com/tryme/template.php?page=dogs'>The Dog page</a><br />"; echo "<a href='template.php?page=cats'>The cat page</a><br />"; echo "<a href='http://www.lunarcafe.com/tryme/template.php?page=mice'>The Mice page</a><br />"; echo "<a href='http://www.lunarcafe.com/tryme/template.php?page=fish'>The Fish page</a><br />"; ?> I have a feeling the answer lies in the template.php?page=fish' PAGE statement here and in $page1 = $_GET['page'] linkage as well Any thoughts? I want to assign the menu links to certain DIV's without changing the information in the first div? The page will be changed when I have a clue what I am doign, this page is for my own learning. There will be at least 4 DIV's Thanks for reading this. |
|
#2
|
|||
|
|||
|
Basically, it works the same way at the DIV level as at the page level -- if a file is to contain a single DIV. If you're wanting to include multiple DIVs in the same file, then you could use something like preg_match() to extract a particular DIV out of a library file of DIVs.
|
|
#3
|
|||
|
|||
|
I see what you are saying, but I was trying to include a file into a particular DIV from a link and have it stay there till replaced. But you have given me a vary good idea with the library or array of $DIV's. Thanks!
|
|
#4
|
|||
|
|||
|
Quote:
|
|
#5
|
|||
|
|||
|
That will be a good learning tool, the sessions and/or the cookie. I have been reading up on sessions and want to try something in that area.
Could you give me an example of such an query string arguement attached to a link? just any example will do for me to get the idea. Thanks. |
|
#6
|
|||
|
|||
|
The link:
HTML Code:
<a href="thispage.htm?div=someid">Some Text</a> PHP Code:
|
|
#7
|
|||
|
|||
|
Excellent, thank you for being so kind.
I see what you did, its almost exactly like a post and get form. Part of whats dificult with this, is that 99% of tutorials dont teach you things like "!empty" and you are left dangling wondering why things dont work. I guess thats why you download scripts, to analyze them Thanks again. |
|
#8
|
|||
|
|||
|
Salud!
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|