tomfmason Posted July 2, 2006 Share Posted July 2, 2006 I have writen a script that was intended to be used for my left_navbar. Which would simply update my left_navbar and my simple bread crumbfile. Ok now to the question.I am wondering if there is an easier way to do the same thing.This is an example of were the variables will be pased from.[code]<?php$filename = "forum.php";$title = "Forum";$cata = "General";$catb = "Apache";$catc = "Mysql";$catd = "Php";$cate = "Css";$catf = "Html";$catg = "Flash";$cath = "Xampp";$catI = "Wamp";$linka = "$filename";$linkb = "$filename";$linkc = "$filename";$linkd = "$filename";$linke = "$filename";$linkf = "$filename";$linkg = "$filename";$linkh = "$filename";$linkI = "$filename";$construct = "true";include("includes/main.php");?> [/code]First this is just a test until I get the forum up and running. the $constuct ="true"; Tells my main.php(the main layout page) that the site is currently under construction and echos the $title to tell the user that the site is down. Is it possible to write an array at the top of this file and then when the forum.php is called another function will print the array into varibles, like above. I would like to have the array dynamicly updated based on content.Here is a copy of a copy of my left_navbar.php [code] <div id="search"> <form action="#"> <label>search</label> <input name="searchfor" type="text" size="a0"> <input name="goButton" type="submit" value="go"> </form> </div> <div id="sectionLinks"><?php if ($title =="The Home Of Owpt") { echo " <h3>Links</h3> <ul> <li><a href=\"index.php\" TITLE=\"The Home Of Owpt\">Home</a></li> <li><a href=\"account.php\" TITLE=\"My Account\">My account</a></li> <li><a href=\"contact.php\" TITLE=\"Contact US\">Contact Us</a></li> <li><a href=\"support.php\" TITLE=\"Support\">Support</a></li> <li><a href=\"catalog.php\" TITLE=\"Catalog\">Catalog</a></li> <li><a href=\"Forum.php\" TITLE=\"Forum\">Forum</a></li> <li><a href=\"tutorials.php\" TITLE=\"Tutorials\">Tutorials</a></li> </ul> </div>"; } elseif ($title=="My Account") { echo " <h3>Links</h3> <ul> <li><a href=\"index.php\" TITLE=\"The Home Of Owpt\">Home</a></li> <li><a href=\"account.php\" TITLE=\"My Account\">My account</a></li> </ul> </div> <div class=\"relatedLinks\"> <ul> <li><a href=\"$linka\" TITLE=\"$cata\">$cata</a></li> <li><a href=\"$linkb\" TITLE=\"$catb\">$catb</a></li> <li><a href=\"$linkc\" TITLE=\"$catc\">$catc</a></li> <li><a href=\"$linkd\" TITLE=\"$catd\">$catd</a></li> <li><a href=\"$linke\" TITLE=\"$cate\">$cate</a></li> </ul> </div> <div class=\"afterLinksLinks\"> <ul> <li><a href=\"contact.php\" TITLE=\"Contact US\">Contact Us</a></li> <li><a href=\"support.php\" TITLE=\"Support\">Support</a></li> <li><a href=\"catalog.php\" TITLE=\"Catalog\">Catalog</a></li> <li><a href=\"Forum.php\" TITLE=\"Forum\">Forum</a></li> <li><a href=\"tutorials.php\" TITLE=\"Tutorials\">Tutorials</a></li> </ul> </div>";} elseif ($title=="Contact Us") { echo " <h3>Links</h3> <ul> <li><a href=\"index.php\" TITLE=\"The Home Of Owpt\">Home</a></li> <li><a href=\"account.php\" TITLE=\"My Account\">My account</a></li> <li><a href=\"contact.php\" TITLE=\"Contact US\">Contact Us</a></li> <li><a href=\"support.php\" TITLE=\"Support\">Support</a></li> <li><a href=\"catalog.php\" TITLE=\"Catalog\">Catalog</a></li> <li><a href=\"Forum.php\" TITLE=\"Forum\">Forum</a></li> <li><a href=\"tutorials.php\" TITLE=\"Tutorials\">Tutorials</a></li> </ul> </div>"; } elseif ($title=="Support") { echo " <h3>Links</h3> <ul> <li><a href=\"index.php\" TITLE=\"The Home Of Owpt\">Home</a></li> <li><a href=\"account.php\" TITLE=\"My Account\">My account</a></li> <li><a href=\"contact.php\" TITLE=\"Contact US\">Contact Us</a></li> <li><a href=\"support.php\" TITLE=\"Support\">Support</a></li> </ul> </div> <div class=\"relatedLinks\"> <ul> <li><a href=\"$linka\" TITLE=\"$cata\">$cata</a></li> <li><a href=\"$linkb\" TITLE=\"$catb\">$catb</a></li> <li><a href=\"$linkc\" TITLE=\"$catc\">$catc</a></li> <li><a href=\"$linkd\" TITLE=\"$catd\">$catd</a></li> <li><a href=\"$linke\" TITLE=\"$cate\">$cate</a></li> </ul> </div> <div class=\"afterLinks\"> <ul> <li><a href=\"catalog.php\" TITLE=\"Catalog\">Catalog</a></li> <li><a href=\"Forum.php\" TITLE=\"Forum\">Forum</a></li> <li><a href=\"tutorials.php\" TITLE=\"Tutorials\">Tutorials</a></li> </ul> </div>";} elseif ($title=="Catalog") { echo " <h3>Links</h3> <ul> <li><a href=\"index.php\" TITLE=\"The Home Of Owpt\">Home</a></li> <li><a href=\"account.php\" TITLE=\"My Account\">My account</a></li> <li><a href=\"contact.php\" TITLE=\"Contact US\">Contact Us</a></li> <li><a href=\"support.php\" TITLE=\"Support\">Support</a></li> <li><a href=\"catalog.php\" TITLE=\"Catalog\">Catalog</a></li> </ul> </div> <div class=\"relatedLinks\"> <ul> <li><a href=\"$linka\" TITLE=\"$cata\">$cata</a></li> <li><a href=\"$linkb\" TITLE=\"$catb\">$catb</a></li> <li><a href=\"$linkc\" TITLE=\"$catc\">$catc</a></li> <li><a href=\"$linkd\" TITLE=\"$catd\">$catd</a></li> </ul> </div> <div class=\"afterLinks\"> <ul> <li><a href=\"Forum.php\" TITLE=\"Forum\">Forum</a></li> <li><a href=\"tutorials.php\" TITLE=\"Tutorials\">Tutorials</a></li> </ul> </div>";} elseif ($title=="Forum") { echo " <h3>Links</h3> <ul> <li><a href=\"index.php\" TITLE=\"The Home Of Owpt\">Home</a></li> <li><a href=\"account.php\" TITLE=\"My Account\">My account</a></li> <li><a href=\"contact.php\" TITLE=\"Contact US\">Contact Us</a></li> <li><a href=\"support.php\" TITLE=\"Support\">Support</a></li> <li><a href=\"catalog.php\" TITLE=\"Catalog\">Catalog</a></li> <li><a href=\"Forum.php\" TITLE=\"Forum\">Forum</a></li> </ul> </div> <div class=\"relatedLinks\"> <ul> <li><a href=\"$linka\" TITLE=\"$cata\">$cata</a></li> <li><a href=\"$linkb\" TITLE=\"$catb\">$catb</a></li> <li><a href=\"$linkc\" TITLE=\"$catc\">$catc</a></li> <li><a href=\"$linkd\" TITLE=\"$catd\">$catd</a></li> <li><a href=\"$linke\" TITLE=\"$cate\">$cate</a></li> <li><a href=\"$linkf\" TITLE=\"$catf\">$catf</a></li> <li><a href=\"$linkg\" TITLE=\"$catg\">$catg</a></li> <li><a href=\"$linkh\" TITLE=\"$cath\">$cath</a></li> <li><a href=\"$linkI\" TITLE=\"$catI\">$catI</a></li> </ul> </div> <div class=\"afterLinks\"> <ul> <li><a href=\"tutorials.php\" TITLE=\"Tutorials\">Tutorials</a></li> </ul> </div>";} else { echo " <h3>Links</h3> <ul> <li><a href=\"index.php\" TITLE=\"The Home Of Owpt\">Home</a></li> <li><a href=\"account.php\" TITLE=\"My Account\">My account</a></li> <li><a href=\"contact.php\" TITLE=\"Contact US\">Contact Us</a></li> <li><a href=\"support.php\" TITLE=\"Support\">Support</a></li> <li><a href=\"catalog.php\" TITLE=\"Catalog\">Catalog</a></li> <li><a href=\"Forum.php\" TITLE=\"Forum\">Forum</a></li> <li><a href=\"tutorials.php\" TITLE=\"Tutorials\">Tutorials</a></li> </ul> </div> <div class=\"relatedLinks\"> <ul> <li><a href=\"$linka\" TITLE=\"$cata\">$cata</a></li> <li><a href=\"$linkb\" TITLE=\"$catb\">$catb</a></li> <li><a href=\"$linkc\" TITLE=\"$catc\">$catc</a></li> <li><a href=\"$linkd\" TITLE=\"$catd\">$catd</a></li> <li><a href=\"$linke\" TITLE=\"$cate\">$cate</a></li> <li><a href=\"$linkf\" TITLE=\"$catf\">$catf</a></li> <li><a href=\"$linkg\" TITLE=\"$catg\">$catg</a></li> <li><a href=\"$linkh\" TITLE=\"$cath\">$cath</a></li> </ul> </div>";}?>[/code] As you can see this is also very repeative. It actualy would have been faster to manuly code it with the actual links. Well maybe not. Anyways, this can be broken down into three dynamic areas. The sectionLinks relatedLinks and the afterLinks. When the person clicks on, say forum , the rest of the links that are below move down and the the relatedLinks are put in its place. So basicly I am wanting to dynamicly store information in the top of a page or maybe some other page..i.e..links.php and inlcude it in my master php file. Here is a link to the site so that you may see it in action [url=http://www.owpt.biz/index.php]http://www.owpt.biz/index.php[/url] Also I am wondering how to use the session.hash.function()? Or some other form of a more secure session? Quote Link to comment https://forums.phpfreaks.com/topic/13430-is-there-a-better-way-to-echoprint-variables/ Share on other sites More sharing options...
Drumminxx Posted July 2, 2006 Share Posted July 2, 2006 you could do something like...[code]$links = array("link0", "link1", "link2");$cats = array("cat0", "cat1", "cat2");for ($i=0; $i<=count($links); $i++) { echo '<a href="'.$links[$i].'">'.$cats[$i].'</a>';}[/code]you can load the link info manually as in the above example or load it from a text file or database for easy updating Quote Link to comment https://forums.phpfreaks.com/topic/13430-is-there-a-better-way-to-echoprint-variables/#findComment-51867 Share on other sites More sharing options...
tomfmason Posted July 2, 2006 Author Share Posted July 2, 2006 Thanks I will do some reasearch...i.e.. The manul. On this subject Quote Link to comment https://forums.phpfreaks.com/topic/13430-is-there-a-better-way-to-echoprint-variables/#findComment-51875 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.