473,395 Members | 1,949 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Using PHP to load part of a page

I want to use PHP to select a file in one HTML DIV and load it in a second DIV on the same page. Then select a second file from the first division for reloading the second DIV.

First, is this possible using PHP?

Second, as a total PHP novice, here is all I have so far, and I know I am missing something.

<?php
if ($_GET["page"] == "home")
include("home.php");
else if ($_GET["page"] == "info")
include("info.php");
?>

How do I display my choices (home and info) on the page? Do I use a list?

Once I make a selection, how do I display what I have selected?

Bill
May 9 '07 #1
4 5754
Yes you can do this in PhP :)

What you would have to do is make a <form> for the selection and set the "Page" variable using it. Then use the submit button to pass the variable. You could also do this with an active Java control.

Since PhP does it's work before the page is rendered, you would have to refresh the page to get the desired content out as the first pass would give the possible choices.

so let me see about some code here :) this is w/o using any javascript as I avoid it like the plague personally. This would be an example of what you would do to render the selection menu.

Expand|Select|Wrap|Line Numbers
  1. <form action = "page.php" method="get">
  2. <input type="radio" name="page" value="page1" checked="checked" >
  3. <input type="radio" name="page" value="page2" >
  4. <input type="submit" value="submit">
  5. </form>
  6.  
this would be some PhP for the selection

Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  
  3. if ($_GET['page'] == "page1")
  4. {
  5. include("page1.php");
  6. }
  7. else
  8. {
  9. include ("page2.php");
  10. }
  11.  
  12. ?>
  13.  
mind you there are a pile of ways to do this, it really comes to personal choice.
May 9 '07 #2
Motoma
3,237 Expert 2GB
I want to use PHP to select a file in one HTML DIV and load it in a second DIV on the same page. Then select a second file from the first division for reloading the second DIV.

First, is this possible using PHP?

Second, as a total PHP novice, here is all I have so far, and I know I am missing something.

<?php
if ($_GET["page"] == "home")
include("home.php");
else if ($_GET["page"] == "info")
include("info.php");
?>

How do I display my choices (home and info) on the page? Do I use a list?

Once I make a selection, how do I display what I have selected?

Bill
What you are looking to do is something that is better done in Javascript, unless you want to reload the entire page each time you change the content of a div.
May 9 '07 #3
Yes you can do this in PhP :)

What you would have to do is make a <form> for the selection and set the "Page" variable using it. Then use the submit button to pass the variable. You could also do this with an active Java control.

Since PhP does it's work before the page is rendered, you would have to refresh the page to get the desired content out as the first pass would give the possible choices.

so let me see about some code here :) this is w/o using any javascript as I avoid it like the plague personally. This would be an example of what you would do to render the selection menu.

Expand|Select|Wrap|Line Numbers
  1. <form action = "page.php" method="get">
  2. <input type="radio" name="page" value="page1" checked="checked" >
  3. <input type="radio" name="page" value="page2" >
  4. <input type="submit" value="submit">
  5. </form>
  6.  
this would be some PhP for the selection

Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  
  3. if ($_GET['page'] == "page1")
  4. {
  5. include("page1.php");
  6. }
  7. else
  8. {
  9. include ("page2.php");
  10. }
  11.  
  12. ?>
  13.  
mind you there are a pile of ways to do this, it really comes to personal choice.
Thanks. I will play around with this and see how it works for me.
May 10 '07 #4
What you are looking to do is something that is better done in Javascript, unless you want to reload the entire page each time you change the content of a div.
Thanks. I will play around with the PHP and see if I can learn something and also see how I like it.

I have never done anything in Javascript except from programs I have downloaded. Guess it is time to learn more.

Bill
May 10 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Mr Wizard | last post by:
I am going through the front controller http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnpatterns/html/ImpFrontControllerInASP.asp and all works well except when the server.transfer...
4
by: Kevin Phifer | last post by:
Ok, before anyone freaks out, I have a solution I need to create that gathers content from maybe different places. Each one can return a <form> in the html, so its the classic can't have more than...
0
by: L Scott | last post by:
I've created a page ancestry (framework) for our application so that all pages in our app would have the same look and feel. To do this, I created several user controls (header, footer, menu,...
10
by: GeekBoy | last post by:
Okay, I have two identical web servers running Windows 2003 web server. I have an ASP.NET application which runs great on one of them. Dedicated IP address, behind our firewall, etc. Everyone's...
5
by: Irfan Akram | last post by:
Hey guys, Just wondered how we can divide the page in two sections, and use one section to load a jpeg image, and the other section to add some other controls to manipulate the jpeg. Useful...
21
by: matvdl | last post by:
I have a system that was originally developed in asp - the pages are saved in SQL (there are over 10,000 pages) and saved to a temp directory in the server when requested by a client. I have...
0
by: mathlec | last post by:
I have 2 WebApplication project (dummy and dummy2). The first is trying to load a UserControl compiled in the second. I've set up the application as follow: \_(Virtual directory) .:Modules:.
5
by: ggk517 | last post by:
We are trying to develop an Engineering application using PHP, Javascript with Informix as the back-end. Is it possible to retrieve data using Javascript but by accessing the Database. Say...
4
by: SandyIsCool | last post by:
Hi, I am newbie to asp.net. I have small doubt regarding page life cycle. MSDN documentaion says that init event does blhah, blah load event does blah blah etc. But Id ont see any init or load...
2
by: rn5a | last post by:
Please have a look at the image at the URL given below: http://rn5a.brinkster.net/Template.gif I would like to use that image as a template for all the ASP pages in a website. Note that though...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.