![]() If this code block is checked manually, the complexity of code increases making it unfavorable. We use switch case specifically, when we need to run only a specific code block, and if the other code blocks do not satisfy the condition, they will be skipped. It is present in languages like C++ or Java. The ‘switch case’ statement is like the ‘if… else’ statement but a cleaner and quicker way than ‘if… else’. Methods to implement Switch case in Python.Include('mssql.php') //Enables PEAR Connection settings ![]() Last night I rethought what I was doing and came up with this, which works exactly the way I want it to This is the first chance I've had to check this thread out this morning. If (in_array($_GET,$files) & file_exists("include/ This seems to be what you want (all people have to do is add a file in the include dir and create the appropriate record). and then, depending on the requested page (link clicked by the user) you include the appropriate file in the "include" directory : ) Then in PHP you query the table, generating one link per record : Link_caption varchar(20) NOT NULL DEFAULT 'link' Link_filename varchar(20) NOT NULL PRIMARY KEY, Module Toad /var/I understand it, you just have to populate a table that references pages, and retrieve these page references to populate your menu.A very simplistic implementation :I suppose you create the table like this : create table menu_link( Module XYZ /var/www/html/includes/modxyz.php We'll say in /var/I'm also going to assume you have some title involved (to show in the drop down menu or list.) Then it'll automatically populate in the menu without having to alter the base code at all.I'll check that link out and see what I can come up with Let me see if I understand this. php file in an include dir and then add a referencing row to the DB. What I want to do is make this a "modular" menu, so when someone down the road decides to make a new module, all they have to do is drop the. Basically I've got a row in a DB that references a php file. Quote:Originally posted by 's also technically not just the content that's sitting elsewhere. Then it'll automatically populate in the menu without having to alter the base code at all.I'll check that link out and see what I can come up with it's also technically not just the content that's sitting elsewhere. it honestly doesn't make much of a difference. Quote:Originally posted by koala:Are you sure you want to do this using functions? Actually, having the list of pages in one place (the db) and the actual content somewhere else (functions) sounds like an odd combination.In any case, I believe you could combine and a map (an array whose index is a string) to get something nice. Normally this would be really simple to do, but I've never tried to use PHP to dynamically generate PHP that it runs at that time.any ideas? Both the querystring value and the function name can exist in the db, so I think it's just a matter of coming up with a loop that can generate this. Basically, I want to call a function (which generates the html I want) depending on whatever link the user clicks. this is a real dumbed down example what I'm trying to dynamically generate. I just am brainfarting about how to actually do it. I know something like this is possible, I think I've even seen it before. What I'd like to do is dynamically generate the case statement somehow. ![]() The table contains all the link information, which, in turn, build some http GET querystrings that get put in the links, which link back to the same page.So my first idea was a simple case statement (like what I usually do with stuff like this), but I then realized that whenever I added a menu element to the application, I'd have to manually add lines to the case statement. Let me know if I'm way overthinking this.Basically, what I've got is a link menu in a web app that is fed from a table in a sql database. It's probably really simple, but it's been a long day and I'm having trouble putting it together in my head. I'm wondering if I could get some help wrapping my head around this.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |