Mr.Fab Posted May 16, 2008 Share Posted May 16, 2008 hi there. I guess I am glad to have found you guys. I do use php for quite a while, but haven't learned that much about OO yet. Now I am writing a webpage, which should only have one php page (and mysql-access). On every hyperlink, the page is supposed to reload itself and call a specific function which does everything to read the mysql data that shows the new page. My basic problem now is, how do I make a link (with the <a href >-style (I guess), that calls a function with two or more parameters? Thanks for your answers! Link to comment https://forums.phpfreaks.com/topic/105935-calling-a-function-with/ Share on other sites More sharing options...
moon 111 Posted May 16, 2008 Share Posted May 16, 2008 You would add a GET request the end of the url. So for example: <?php if($_GET['do_something']) { // ... } elseif($_GET['do_something_else']) { // ... } else { // Show links } ?> and the links would be like: somepage.php?do_something=true Link to comment https://forums.phpfreaks.com/topic/105935-calling-a-function-with/#findComment-542915 Share on other sites More sharing options...
Stooney Posted May 16, 2008 Share Posted May 16, 2008 First off, this isn't on OOP question. As for your question I'm kinda going out on a limb here because your question didn't make too much sense, but I think you want the $_GET array. So each link will look like this: <a href="index.php?action1=cat&action2=pet">Click Me</a> Now in your index.php (or wherever): <?php switch($_GET['action1']){ case 'cat': include("cat.php"); break; } switch($_GET['action2']){ case 'pet': echo "You have pet your cat"; break; } ?> Hope that made sense and sorry for the cheesy examples; it's too early. Link to comment https://forums.phpfreaks.com/topic/105935-calling-a-function-with/#findComment-542916 Share on other sites More sharing options...
Mr.Fab Posted May 16, 2008 Author Share Posted May 16, 2008 *clapping hand to my head* Of course. Well, actually it was a OOP question, but your answers made it a non oop question. The actual answer is a mix of both of your answers. I did think about the case routine, earlier myself, but somehow it didn't for out for me. Now it does. Thank you you two. [sOLVED] Link to comment https://forums.phpfreaks.com/topic/105935-calling-a-function-with/#findComment-542934 Share on other sites More sharing options...
Mr.Fab Posted May 16, 2008 Author Share Posted May 16, 2008 http://www.phpfreaks.com/forums/index.php/topic,118755.0.html Link to comment https://forums.phpfreaks.com/topic/105935-calling-a-function-with/#findComment-542945 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.