Jump to content

calling a function with <a href=...</a>


Mr.Fab

Recommended Posts

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

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.

*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]

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.