PHP - Making 1 Navigation File To Control Entire Site
Hello:
I have a question. I use to - when I was doing Classic ASP - make a single navigation file to include all aspects of site navigation. I'm trying to do that now in PHP, but keep getting errors. Can some set me straight (I am assuming what I want to do can be done in PHP). I have my myNav.php file (in an "include" subfolder): Code: [Select] <?php function showLinks() <script type="text/javascript" src="include/spNewWindow.js"></script> <script type="text/javascript" src="include/openSesame.js"></script> <link rel="stylesheet" type="text/css" href="include/StyleSheet.css" /> ?> <?php function showTopMenu() <a href="#">Link 1</a><br /> <a href="#">Link 2</a><br /> <a href="#">Link 3</a><br /> ?> This is the myPage.php I am trying to pull it in to: Code: [Select] <?php include('include/myNav.php'); ?> <html> <head> <title></title> <?php echo $showLinks; ?> </head> <body> <div id="myMenu"> <?php echo $showTopMenu; ?> </div> ... REST OF SITE, ETC ... </body> </html> However, this is not working at all. I have figured out how to make files for each individual aspect - Menu, Footer, META tags, etc - but I would like to do this with one file as shown above. Is this possible? Thanks! Similar Tutorials$connet = mysql_connect("host", "db_username", "pass") or die(mysql_error()); $user = $_SESSION['SESS_FIRST_NAME']; mysql_select_db('db_name, $connet) or die(mysql_error()); mysql_query("SELECT members Get $earn='earned' WHERE $user='username' LIMIT 1;"); $earn = $total_earn; ?> <a>$<?php echo "$total_earn";?></a> I have two domains. I'd like to replace a word depending on the URL the user has typed in. For example: Original site is all about red pens. Well I want to make another domain that is bluepens.com, but when they enter in bluepens.com it uses the same pages from red pens except wherever the word 'red' is found it is changed to blue pens making it a whole new site. I know I can use str_replace() for certain instances, but how would you do it for an entire website using the url? Thanks! This topic has been moved to Apache HTTP Server. http://www.phpfreaks.com/forums/index.php?topic=358740.0 I'm trying to control the load order of the browser. The default load order is from top to bottom. Well I have a table that is made in html with more code bellow the table. My php data that I put inside the html table is Code: [Select] <?php include("table/table.php"); ?> that grabs the data that will go into my html table. Well the problem I'm having is that the rest of the table with stuff under the table won't load till the php is done being processed. This makes my site look weird for 4 seconds and is the reason why I want to load the php content last. Is there a way to do this with php or javascript? I was wondering of it was possible to have a file say style.css in the root folder of a site like www.example.com/style.css and then get a subdomain called www.sub.example.com which points to www.example.com/subarea to get that file without the use of absolute paths? Sorry if its not clear. hello. i wonder if anyone could help me to solve this puzzle. im trying to create a dynamic navigation using a database but i keep getting stuck. i have 2 database: Navigation with : Quote id navPos pageID level parent url 1 top 1 1 0 page1.php 2 top 2 2 1 page2.php 3 top 3 3 2 page3.php 4 top 4 3 3 page4.php 5 top 5 3 4 page5.php 6 top 6 3 5 page6.php and Pages with: Quote id pageName 1 page1 2 page2 3 page3 4 page4 5 page5 6 page6 now, what i want to happen is on each page i have 3 functions. 1 calling the top nav, 1 calling the side nav and 1 calling the bottom nav. for this each function should have 3 levels. level 1 = main top level level 2 = child to main top level level 3 = child to level 2 so for example. 2 tabs each with 3 levels and 1 page on each level. TOP NAV Quote levels - TAB 1 - TAB 2 LEVEL1 - page1 - page4 LEVEL2 - page2 - page5 LEVEL3 - page3- page6 now for the code. I'LL STICK TO JUST THE TOP NAV FOR NOW. on the page that will display the navigation's i have: I WOULD LIKE THEM TO DROP DOWN BUT THIS CODE WILL NOT DO THAT. just lists for now Code: [Select] <div id="navWrapper"> <?PHP $navPosion = "top"; ?> <div id="LEVEL1" class="LEVEL1"> <ul><?PHP echo Navigation::NavL1($pageID, $navPosion); ?></ul> </div> <div id="LEVEL2" class="LEVEL2"> <ul><?PHP echo Navigation::NavL2($pageID, $navPosion); ?></ul> </div> <div id="LEVEL3" class="LEVEL3"> <ul><?PHP echo Navigation::NavL3($pageID, $navPosion); ?></ul> </div> </div> these is the functions im trying to put together. in the Navigation class i have. Code: [Select] class Navigation extends Pages{-----lots of other code here.... public static function navL1($pageID, $navPosion){ //FIND CURRENT PAGE ID $page = new Pages(); //calling just the Pages class. $CP = $page->find_by_pageID($pageID); $CPid = $CP->id; //GET ALL PAGES FROM THE DB $allP = $page->find_all(); foreach ($allP as $allPs){ $allPname = $allPs->pageName; //GET INFO FROMTHE NAVIGATION TABLE $nav2 = new Navigation(); //calling the navigation extension $Cnav = $nav2->find_all(); foreach ($Cnav as $Cnavs){ $Nid = $Cnavs->id; $Npos = $Cnavs->navPos; $Npid = $Cnavs->pageID; $Nlevel = $Cnavs->level; $Npnt = $Cnavs->parent; $Nurl = $Cnavs->url; $Nord = $Cnavs->order; if($Nlevel = '1'){ //FIND ACTIVE TAB if($CPid == $allPid){ $selected_tab='class="selected"'; }else{ $selected_tab=''; } echo '<li><a '.$selected_tab.' href="'.$allPname.'.php">'.$Nlevel.''.$allPname.'</a></li>'; }// if($Nlevel == $navLevel //} //end Navigation() }//end foreach ($allP as $allPs) } //end getNav($pageID) THEN THE SAME AGAIN FOR : public static function navL2($pageID, $navPosion){ and public static function navL3($pageID, $navPosion){ what this does is list all the pages for example navL1 give me Quote page1 page2 page3 page4 page5 page6 i want it to only list where level is 1 or 2 or 3 in each of the functions i have this but it does not seem to work. Code: [Select] if($Nlevel = "1"){ i tried this but i nothing return. Code: [Select] if($Nlevel == "1"){ if i echo this out in navL1 Code: [Select] echo "<br/>".$Nid = $Cnavs->id; echo "<br/>".$Npos = $Cnavs->navPos; echo "<br/>".$Npid = $Cnavs->pageID; echo "<br/>".$Nlevel = $Cnavs->level; echo "<br/>".$Npnt = $Cnavs->parent; echo "<br/>".$Nurl = $Cnavs->url; it gives me back the last page (page6) 6 time over which is not even level1. its level3 Quote 6 top 6 3 5 page6.php so its missing the rest of the pages in the loop and just out putting the last one. i realise that i need more if's in my function but maybe there is a better way ? for example i need an if($Npos == top) and in navL2 and navL3 i need to only show sub tabs under the correct parent. etc... for now i just want to get what i can working .. any thoughts ???? maybe i can roll all 3 functions into 1 amazing function ???? that would be nice. thanks ricky As we know , A post_max_size used to limit the size of posted data via POST method while the upload_max_filesize used to limit the size of file to be uploaded
I assume. post_max_size = 8m upload_max_filesize = 2m
When i limit the user to only upload 100kb file, i say <pre>
if (!empty($_FILES["myfile"]["tmp_name"]) && ($_FILES["myfile"]["size"] > 100000)) { </pre>
This message occur even when the file is greater than 8 m
The problem come when the file is greater than 10m the warning message for post content is on the page is
Warning: POST Content-Length of 9767236 bytes exceeds the limit of 8388608 bytes in Unknown on line 0
What i want? I want to create my own warning as an error
ie <pre>
if (post_max_size > 18388608)) { </pre>
NB: some developers says we have to adjust the post_max_size i.e 200M what if user upload the file with 210M, the warning message will come back again
Warning: POST Content-Length of 9767236 bytes exceeds the limit of 8388608 bytes in Unknown on line 0
In short i want to give a normal user a meaningful warning
In one of my pages I have a section which contains a hidden line of text. When the user clicks a button the box containing the text will expand showing the line more clearly. I want this to happen live i.e. no page refresh/reload. I've seen such things done on other sites but my question is, is this done using a php function or is JavaScript required to achieve this? I assume that in order for any php functions to take place there must be a page refresh to reload the data/parameters/variables that are required? The site I'm referring to is this one:- http://www.vouchercodes.co.uk/featured-voucher-codes.html If you click on the "Get code and open site" buttons there for any of the vouchers the area expands live and the voucher is revealed however as I say there is no page refresh and it is done live. Is this effect done in JavaScript and not php or is there some way of using php alone to do something similar? Obviously including JScript in a site is more risky as if a user does not have it installed/activated then they may not be able to use such elements hence the reason I want to know how it is done. I was talking to some friends, who are just as new as me in programming, and they think it would be better to use a single navigation file for every link in a web site. Something like this: Code: [Select] <a href="nav.php?id=home&otherparams" >Home</a> <a href="nav.php?id=products&otherparams" >Products</a> <a href="nav.php?id=contact&otherparams" >Contact</a> I told them I think this might be easier to maintain, but also might take up on loading time, as the site viewer will have to go through an extra node to get where he wants. Is this single navigation file a good practice or should it be avoided? Thanks for any comments... Hi, I have a file structure for all my files on my website that works fine for the most part. The basic layout would be something similar to the following. - root folder - sub_folder1 - folder1 - folder2 -sub_folder2 - folder1 - folder2 Each of the folders would contain relative .php files carrying out specific functions etc. The issue I am having is as follows. If I am on a webpage that is located in either of the folder1/folder2 folders, and I need to redirect somebody to a file located in the root folder, I am not able to do this without the page not being displayed correctly. On the file located in the folder1 folder, I have a <? php include("page1.php");?> which works fine. Trying to access a file to redirect to from this folder, I have tried, <? php include("../page1.php");?>, but this only bring me up one level, <? php include("../../page1.php");?> which I think is wrong anyway, and doesn't work, and also <? php include("./page1.php");?>, again does not work. Does anyone know if it is possible to get the file from the subfolders to access a file located directly in the root? Sorry if I'm not being clear explaining the layout etc. Thanks. Selected navigation on include file. Hi all I can't think how to do this or even if it's possible so I'm hoping someone can help. I have a simple example here to illustrate. http://www.ttmt.org.uk/three.php It's just four linked pages with a heading and a navigation. The navigation has an id="selected" in the <a> tag for that page that changes the color of that link to show you are on that page - very basic. I wanted the put the navigation on the pages with an include file. Code: [Select] <?php include("php/includes/nav.php"); ?> and have the code for the nav in nav.php nav.php Code: [Select] <ul id="nav"> <li><a href="index.php">Home</a></li> <li><a href="one.php">One</a></li> <li><a href="two.php">Two</a></li> <li><a href="three.php">Three</a></li> </ul> My problem is how can I add the id="selected" to the different links for the different pages if I'm including the navigation code? Hope this makes sense and someone can help. Any help would be greatly appreciated. I am trying to make PHP output a file in html and using the following code. Code: [Select] <?php readfile("./1/index.html"); ?> ... but it isn't working. How would I get PHP to output a file as HTML? I have been spending the majority of this week figuring out why my files are not showing up at my upload location that I set up in my newly created simple upload form. It just seems like php doesn't like me at all. Here is what my code looks like below. Code: [Select] <?php if (move_uploaded_file($_FILES['thefile']['name'], $upload_file)) $destination = "/www/zymichost.com/m/t/l/mtlproductions/htdocs/"; $upload_file = $destination . basename($_FILES['thefile']['name']);{ echo "Your file has been uploaded successfully!"; }/* else { echo "Your file did not upload successfully. Check to make sure your file meets the requirements and then try again."; print_r($_FILES);}*/?> I have the orange marked areas commented out due to the unexpected T_ELSE error thing. What do I do to get my files to show up at my upload location when I use my upload form? Thanks! Can someone help me out with making a bat file. I cant find a good set of directions on google. I have window scheduler all working in running but it runs my script in note pad and not IE like I need it too. I also read something about php cgi file for doing this same thing but cant make heads of tails out of it from reading about it in the manual. Trying to run this http://localhost/gate/users/update.php I try to publish my web site today . I choose www.netfirm.com to store my web pages. However , this is not working. I get error message. Cannot read /mnt/w0500/d04/s15/b0322718/www/ptiimaging.ca/.htaccess. I do not know how to fix this problem . Please tell me how to fix it . Thank you very much. Is thier some code I can use to Notifiy me of files that are downloaded from my site. I would like to put some public files (PDF) in a folder to where the public could download what ever, but I want to know who downloaded these files. Dont know much more than that just got the idea from another site cause they new I downloaded a file and I thought it would be a good idea on may site to do something like that. I am a newbie. I need some guidance for logging onto an existing site, and downloading files. Some tips what I should be looking for? Thanks. This topic has been moved to Other. http://www.phpfreaks.com/forums/index.php?topic=320387.0
Hello everyone,
function get_file_data( $file, $default_headers, $context = '' ) {
/** Hey everyone. Currently I have a site set up where I manually edit the txt file and the site pulls it from the text file and displays via php. I wanted to automate it by creating one file which contains the sunset times for the whole year, and have php determine todays date and then display the corresponding sunset time. Can someone please point me in the right direction? maybe it can be set up in a way where each line in the txt file represents the day of the year. ex: Jan 1 would be line 0, Feb 1's sunset time would be on line 31 etc. Thanks |