Jump to content

Count_Zero

Members
  • Posts

    17
  • Joined

  • Last visited

About Count_Zero

  • Birthday 12/14/1953

Previous Fields

  • Languages
    Learning php, sql, java script, css, pearl

Profile Information

  • Location
    Houston, Texas
  • Interests
    I'm the poster child for adult ADHD, so you could say I'm interested in more stuff than I have the time for.

Count_Zero's Achievements

Newbie

Newbie (1/7)

1

Reputation

  1. Well that's great Bert, glad you have something your happy with up and running, and it has made for a very productive thread. After all we now have what 3, or 4 very interesting solutions to this common problem, and anyone who comes across this tread while searching this issue certanly has a choice of solutions to meet their skill level, what ever that may be. I know I learned seome new things whilist looking up information, and at the same time found not only some flaws in some of my own code, but learned some new ways to do things. @dsonesuk I like that last solution, though still getting my head around it all, but it was the string replace idea you posited as a solution in a previous post that has given me some ideas on some interesting (well maybe kind of wild) menu - link solutions. That’s a can I want to keep kicking down the road when I get the chance. It just might be part of a solution to some things I am trying to do on a large project I have been working on for awhile now. I also need to improve my knowledge of string functions, and it would be like killng two birds with one stone.
  2. OK Bert, this will work perfect for you, and it's simple css. All your styles for the menu work as normal and this only becomes active to the menu item for the current page, when on that page. Add a ID to the body tag of each of the pages which will be linked to from the menu bar like so. <body id="home"><body id="about"><body id="appear"><body id="credits"><body id="holmes"><body id="pub"><body id="contact"> Now in your menu.php include file add a unique ID to each anchor tag (<a>) linke so. <ul id="menu"> <li> <a id="m_home" href="index.php" title="Bert Coules">home</a> </li> <li> <a id="m_about" href="biog.php" title="Bert Coules"><span class="normal_spacing">about me</span></a> </li> <!-- What is this span-class thing for? --> <li> <a id="m_appear" href="appearances.php" title="Appearances">appearances</a> </li> <li> <a id="m_cerdits" href="credits.php" title="Credits">credits</a> </li> <li> <a id="m_holmes" href="holmes.php" title="BBC audio complete Sherlock Holmes"> <span class="normal_spacing">Sherlock Holmes</span></a> </li> <!-- What is this span-class thing for? --> <li> <a id="m_pub" href="publications.php" title="Publications">publications</a> </li> <li> <a id="m_contact" href="contact.php" title="Contact me">contact</a> </li> </ul> Now either in the head, or your external style sheet (preferred) add your selector styles like so. body#home a#m_home,body#about a#m_about,body#appear a#m_appear,body#credits a#m_credits,body#holmes a#m_holmes,body#pub a#m_pub,body#contact a#m_contact { color:rgb(204,204,204); /* This is the RGB value for #cccccc*/ background-color: rgb(0,0,0); /* This is the RGB value for black, set it for what you want the bg to be.*/ } Now I tested this on my dev site, and it works like a charm. If you add the css selectors to an external style sheet along with a menu include file you can manage the menu for all pages from those two files. You could probably copy-paste this just like I have it and it will work.
  3. First a correction for my solution, dsonesuk, and Bert's, and that being we are changing the class on the a:active selector, and it has nothing to do with wither you're on the current page or not. All a:active does is act as a style attribute for onclick, and what needs to be changed for the current page are the a:link, and a:visited selectors because they show the default static condition of the element. Another thing to remember is that a:hover has to come AFTER a:link and a:visited to work, and a:active has to come AFTER a:hover to work. There is a simple all css solution I just tried (and modified) that is not only simple, and easy to setup, but also allows for a menu include file. I will create a demo that matches Bert's situation when I get the chance.
  4. @dsonesuk LMAO! Now that is clever! Store the menu as a text string in one $var, and use a simple str_ireplace conditional. Eligant, simple, and in a word, brilliant. My hat's off to you. The power of the forum! From one question many have learned, and might be inspired to try something new, therefore increasing their overall knowledge. To be honest, and I'm going to go out on a limb here in assuming dsonsuk might have come to the same conclusion, I learn more from helping others solve issues such as this on forums than by any other means. I am by no means a professional programmer, I am totally self-taught as probably most of you are, and because of the way I am, teaching myself while asking questions is just how I learn things. That being said, there is no way you will encounter all the scenarios, or problems you can encounter as a programmer-web developer by yourself in a life time, and that is where helping solve interesting problems posted in forums comes in. It’s a perfect place-medium to gain not only knowledge, but the experience of having applied that knowledge to solve a problem, and that’s knowledge that sticks with you. @Bert That and adding an additional page, and it is the reason for the include file. Make a change in one file and every page is updated. I include the header, menu, footer, and even create a new page with a template.php include file. I see your point, that being it's a static site rarely changed, but in your reasoning, you almost contradict yourself (well you are actually). By this I mean you mention that you started redoing your site, you discovered you had to relearn all the basics again, and now you have a fresh, new, and better site, so why stop at the menu. Don't get me wrong, I'm not riding you about it, rather I'm trying to push-inspire you into learning something new, that when you next update, it will be much easier to do, as well as maintain until then. Of course your tried and true method will work, and if you’re comfortable with that, by all means use it. I guess my point would be, if Edison was satisfied with the coal oil lamp, would we have the light bulb?
  5. @Bert It means your learning new things, and we all are learning at the same time as you because forums are the greatest tool for learning by colabritively sharing knowledge with other like minded people while working together to solve problems. I learned a lot by trying to help you as did others because I (we) had to do a lot of research, and poring over my own code to produce a demo so you might better understand. I didn't even know this forum existed, but have been using w3schools as a reference for years, and in my opinion it's the best out there. I am no stranger to forums, and run battlefieldsingleplayer.com where our forum has been up and running since 2003, and now has just south of 9000 members globally. Every game AI coder worth his salt cut their teeth on our forums, and still do today. That being said, please keep asking questions, and the only dumb thing about any question is why you didn't ask it in the first place. This is a problem that I want to solve myself for my own menu systems, and I bet there are many others with the same interest. I plan to set it up and make it work on my tutorial development site since I already have everything in place. and run the menus via links srored in a db table. Once I have it working how I like, I will post the results here. LoL, I'm funning with you here so don't get your feathers up, but I have to chuckle at the "ultra-simple solution" with the "seven separate menu files each of which differs in a slightly different way" part of that statement. Me thinks we need to help you with a little basic php and sql, and then I think you will get your head around the concept.
  6. Oops that got copy - pasted in there by because I was quickly assembling the demo form other bits and pieces of code without having to type it all out, I tend to be lazy in my old age. Of course you don't need that in a while statement. My bad. Anyhow yea that looks clean, and I just got an email from a bud over at stackoverflow who tried my method and say it works like a charm. There is a CSS solution that does work pretty well, and that is to give each page, a unique to that page, ID in the body tag, and the css for that tag has the current page style. You then add an ID to each a tag in the list corresponding to that page's body ID. That way that ID does not become active until you’re on that page, and the ID in the a tag in the menu will use this style. Give me a moment and I will do a demo. One interesting style idea I found used css to style the menu bar to look like JQuery tabs. The menu bar and main content box touched each other (no margin or padding), and the top border for the content box was the same as the box background, with a black border around each menu link. When on the active page it restyled that menu link to have the same background color as the content box and removed the bottom border therefore giving it a tabs appearance.
  7. First off the pusedo class element a:active is not designed to show the current page because it is only active on click, and returns to the normal state (a:link or a:visited) when you release the mouse button. Second thing is that a:hover has to come after a:link and a:visited, and a:active has to come after a:hover for it all to work. I did a lot of research on this last night, and it is a very popular question with all kinds of complex and crazy solutions. I did find an elegant jave script solution, but it is not as clean as my suggested solutions above using php. I don't know if I'll have time today, but as soon as I can I will set it up and get it working on one of my working dev sites then post it back here.
  8. I've been looking over your code, but at the same time noting this is only part of the whole, and don't see anything out of order, at least nothing that jumps out at me. That being said let's look at your description of the problem you "began having at some point in time," but "before that point in time" it was working fine, right? Now unless you made changes to the code in question at the time it started malfunctioning, then do you know when the problem started, and what might have changed? Was there a software upgrade(s), a program ini change, or new code - software added that might affect your application? Have you checked your send mail settings in the php ini file? What I am saying here is that maybe it's not your code because it doesn't seem to be creating any kind of error, and it seems to me, from looking over your code, you have error traps set at every point so it should flag something, and so it would seem the problem might be server - host related, or a setting has been changed due to an upgrade. I manage 27 domains over 3 different host for clients, and I am always having headaches from the unintended consequences of upgrades. Like I said, I'm only seeing part of your whole app, or order form, and I would surmise it's all part of a shopping cart, but I don't understand why you’re going to all the trouble of validating the email instead of leaving validation to the form then, sending the email on a successful submit to the database, but then again I could be misreading your post too. Now I do something that is very similar with a equipment pickup request form, which just like your sales form, is a request for services to be rendered, right, but I do it all with the form, then on submit with a successful insert, a script query’s the database for the information (already clean and valid) to send in the confirmation email.
  9. No problem Bert, and given time perhaps myself and Jonathanks can show you some examples of how you can do this with css along with a cross browser solution if necessary. What you have to get your head around in the above examples is that the browser doesn't see the php, rather php builds the html page on the server and sends the coded html page to the client (you and your browser) with the menu coded in html. I think I said that right.
  10. @Jonathanks I totally agree that using css, and especially the psuedo class - element a:active, would be the propper way to do this, but I have also found that not all browsers, or browser versions that someone might be using support this feature, and as web developers we always seem to be working around some sort of cross browser complience issues or the other, right. But thanks to the many languages we now have at our disposal, and the cleverness of the human mind (well some anyhow, LoL); there is always more than one way to skin a rabbit. That being said I find you a person of interest, and from the content of your post someone that has a good working knowledge of the topic that I want to tap into. I find forums an awesome educational tool because of the ease in which one can share knowledge in an open source way. In other words they can become a virtual classroom. What I came up with for Bert was something I just pulled out of my head from the idea behind dsonesuk's post, but thought mine a more simple and cleanway to do it. @BertCoules You can do the same thing with your menu setup if you wanted to, and I will give you an example in a moment, but first let me say that the UL makes for the best menus, and there is a nice basic css navbar tutorial here; http://www.w3schools.com/css/css_navbar.asp . You would have to have three columes in your table. You will need link, title, and name for each corrsponding link. It would be something like this, but I did this quickly so there could be an error or two. <div id="menu_bar"> <p class="menu"> <?php include("connect.php"); $result = mysql_query("SELECT * FROM link_table"); while($row = mysql_fetch_array($result)) { $link=$row['link']; $title=$row['title']; $name=$row['name']; if ($link==$_SERVER['PHP_SELF']){ $class="white"; }else{ $class="standard"; } echo "<a class='" . $class . "' href='" . $link . "title='" . $title ."'>" . $name . "</a>"; $row++; } mysql_close($con); ?> </p> </div> <!-- menu_bar --> Study php echo parameters and the append operators (. and .=) if you need clarification on how the output works.
  11. Well right off the bat, and this is simple and quickly done so there could be a sayntax error or two, but (in theory) should work. First create a table in your database, and name it something like link_table, fitting right, single field, varchar, and lenght at 255 should do. Now to load it with your links, open an blank office spreadsheet and list your links down one colume, and then save as a MSDOS CSV file. Now import this csv file into your link_table and it should be loaded. Next add your two classes to your css file. Create a new text document in a text editor ( I use Notepad++ because it rulz!), but DO NOT use word pad or word, if you don't have something Notepad++ (or similur) then just use Notepad. Else you will get formatting you don't want. Ok now name it menu.php and add the following code; <div id="menu"> <div id="list"> <ul class="menu"> <?php include("connect.php"); $result = mysql_query("SELECT * FROM link_table"); while($row = mysql_fetch_array($result)) { $link=$row['link']; if ($link==$_SERVER['PHP_SELF']){ $class="white"; }else{ $class="standard"; } echo "<li class='menu'><a class='" . $class . "' href='" . $link . "'>Link Name</a></li>"; $row++; } mysql_close($con); ?> </ul> </div></div> Now right where you want your menu appear add this line; <?php include("menu.php");?> Now your index page, or web pages, will need to use an .php extension instead of .html for this to work btw, The query loads the array varable $result with the list of links. The while statement will return true, and runs as long as there is data, or in your case links in the array, and returns false when it reaches the end. The $_Global "$_SERVER['PHP_SELF']" holds the value of the location (link) of the current document (webpage), so the link that matches in the conditional gets the white class applied. To add or remove links just add or delete them from the link_table.
  12. If I'm understanding you correctly Bert, you want the link in the menu highlighted when your on that page for that link, right, so that a glance up at your menu will tell you which of your pages your on. If so there are many ways to go about it, but javascript, or php would be the best way to go. One thing is for sure, and as dsonesuk suggest, you want your menu as an include file, I mean this is just the common sense way to do it. Something else you might want to look into is JQuery tabs, and you can download a easily editable package from their site. I would do something like dsonesuk mentions, but I would put my links in a table and run it from a query, output the menu with php echo, and use a simple if/else conditional to flip the css class for the link that equaled the location. I will see if I can do a simple demo for you when I get the time.
  13. This should do the trick. I have it as a php to use a php include file for the menu, but do away with that and script a menu and you an rename it to html. Just add the java script in the document head and make additional edits to the links it should work for you. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title> Go Ther Example. </title> <link rel="shortcut icon" href="images/favicon.ico" type="images/x-icon" /> <link rel="stylesheet" type="text/css" href="style.css" /> <script language="javascript"> function goThere() { var list = document.forms[0].urlList; location = list.options[list.selectedIndex].value; } </script></head><body> <div id="main_container"> <div id="header"> <div class="head"> <div class="img_head"> <img class="header" src="images/logo.gif" /> </div> </div> </div> <?php include("../menu.php");?> <div id="main_content"> <div id="content"> <h2>Select a location.</h2> <div id="audit_form"> <div class="audit_l"> <form name="f1"> <fieldset class="audit_form"> <legend class="audit_form">Go There:</legend> <select name="s1" onChange="window.location=document.f1.s1.options[document.f1.s1.selectedIndex].value"> <option value=" " selected="selected">-Select-</option> <option value="http://www.somewhere.com/place_one/index.php">Place One</option> <option value="http://www.somewhere.com/place_two/index.php">Place Two</option> <option value="http://www.somewhere.com/place_three/index.php">Place Three</option> <option value="http://www.somewhere.com/place_four/index.php">Place Four</option> <option value="http://www.somewhere.com/place_five/index.php">Place Five</option> </select> </fieldset> </form> </div> </div> </div> </div> </div></body></html>
×
×
  • Create New...