Hello! How can I access a script from a directory when I currently executing a script from another directory of the same level as the first directory? Example:
I have a script that prints a form containing a drop-down menu. It is located in http://localhost/root/scripts. The options of that menu will come from a script in http://localhost/root/queries.
http://localhost/root/scripts/menu.php:
<form name='input' action='index.php?page=queries/insert_class' method='post' >
<p><label for='addcl_ctitle'>Course Title: </label><select name='coursetitle' id='ctitle_menu'><this is where i put the option-generating script></select></p>
</form>
I'm OC when it comes to files, so I don't want querying scripts(the options are queried? from a database) in the same folder of my form-generating scripts. Is there a way that I can implement this? I'm a beginner in PHP so I don't know if this is possible.
Thanks in advance!
Scripting from different directories of the same level
Moderator: General Moderators
-
jalbautista
- Forum Newbie
- Posts: 5
- Joined: Mon Jul 20, 2009 10:50 am
-
jalbautista
- Forum Newbie
- Posts: 5
- Joined: Mon Jul 20, 2009 10:50 am
Re: Scripting from different directories of the same level
hahaha don't bother answering... I found it. I can access it using $_SERVER['DOCUMENT_ROOT']. Silly me 
Re: Scripting from different directories of the same level
You could also use '..'
'..' basically means "root directory". It works like this:
A folder called 'data' has two subfolders, 'big' and 'small'. You want to include a script from the 'small' directory in a script in the 'big' directory. You'd write it like this in the script in the 'big' directory:
That's saying "move back into the root directory (data), and then go to the 'small' folder and then include the file.php file".
'..' basically means "root directory". It works like this:
A folder called 'data' has two subfolders, 'big' and 'small'. You want to include a script from the 'small' directory in a script in the 'big' directory. You'd write it like this in the script in the 'big' directory:
Code: Select all
include "../small/file.php";-
jalbautista
- Forum Newbie
- Posts: 5
- Joined: Mon Jul 20, 2009 10:50 am
Re: Scripting from different directories of the same level
Thank you very much! I'll try that. 