Forum Moderators: coopster

Message Too Old, No Replies

PHP Scripting ...minor Help Plz..

Inluding files in a specific area

         

silk

11:08 am on Aug 11, 2004 (gmt 0)

10+ Year Member



PHP verynewcomer.

I have a webpage(say index.php) with a sidebar. (A <div>) When i click on a link in the bar, i want to include a php file into the same index.php, in a specific <div> area. So, the page remains, but the content of the div changes depending on the link clicked. I have seen this effect on websites. Is it possible to emulate using php?
What's the concept behind it? I think it will involve a php function with switch statements. Problem is, how do i call this function from a hyperlink (html)?

henry0

12:33 pm on Aug 11, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome on Webmaster World
first you need to be sure that your html doc will parse a PHP script

it will be done through .htacces doc

Find or create an ".htaccess" doc
That will contain:

RemoveHandler .html .htm
AddType application/x-httpd-php .php .htm .html

Next to include the PHP script in your html do:
<html>
<head></head>
<body>
<h1>
<?php
include "my_php_script";
?>
</h1>
</body>
</html>

keep in mind that you can call the php script from any level using ../../ etc...

silk

6:56 pm on Aug 11, 2004 (gmt 0)

10+ Year Member



Thx, but i configured it and stuff to parse the php documents. My problem is, how to call a php function or script, from a href. When i click on a hyperlink, some function will include a chosen page into a <div< area.

How do i 1) embed the call to php in a href?

2) If 1) works, can i specify where i want the included file to go, mainly in a <div> area on the SAME PAGE.

So u click on links, and on the right of the links, the content changes depending on the link.

All the .htaccess and stuff works. This is the 2nd day i'm doing PHP, so its just inexperience with PHP syntax.
thx.

henry0

10:17 pm on Aug 11, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi
mostly you need to check if a page exists
if it exists display it

here is a simple tutorial

but before going in depth I will encorage you to read about the basics of PHP

[developerfusion.com...]

silk

4:01 am on Aug 12, 2004 (gmt 0)

10+ Year Member



I GOT IT! I FIGURED IT OUT!

Use query strings in the href, and write the switch statement in the <div> where you want the dynamic data.
*whew*

Sorry for the bother!

So if anybody has a problem placing "included stuff" somewhere on a page there is it. So simple. AARRGGGHHH.

Henry0, i never had a problem configuring the .htaccess or even learning PHP basics. The problem here was, u're clicking on a hyperlink in a <div> say <div A>, and you want to include the stuff, in a TOTALLY different <div> say <div B>, that may be on the opposite side of the page. Fear not, i got it now. Prayer works!

henry0

11:32 am on Aug 12, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Silk
Great Job :)
glad it worked out for you