Jump to content

How to use URL to select another function inside the same PHP?


Terje_Hvidsten

Recommended Posts

Hi,

I'm an novice/intermediate PHP prgogrammer, so excuse me if this is a stupid question.

 

I have one php program that consist of a few functions. Inside the function taht is the starting point I pickup a few entries from a MYSQL database, and display those in my html page.

 

I wish to dynamically put a link on those entries that makes it possible for the users to click those entries an get directed to other functions inside this very same PHP program WITH a parameter. The parameters that should accompany the url/link into the selected function to be able to select apropriate records from the mysql tables.

 

Any hints and tips for this would be highly appreciated!

 

Kind Regsrds,

 

Terje Hvidsten.

Link to comment
Share on other sites

You need to use the get parameter. This allows you to pass variables into the URL:

 

Http://www.somesite.com?var1=something&var2=somethingelse&functionparam=function1



// to get data from URL
If ($_Get['functionparam']=='function1')
{
$var1 = $_GET['var1'];
// run function
}

 

I hope this is what you are referring to

Link to comment
Share on other sites

Thanx.

 

I have tried out something like that with no success. It might be that I should have supplied some more information.

This is running on a Zikula site where I have the link http://www.myweirdsite.no/index.php?module=4-GO, where "4-GO" is the directory in my "modules" directory in the Zikula structure. And the php procedure inside this directory that starts is index.php.

 

Inside this "index.php" I have a function() called DisplayPlaces which I want to go to when a user hit one of the 3 linkes on the starting page.

When I now hit the link I get the URL http://www.myweirdsite.no/index.php?module=4-GO&func=DisplayPlaces , but I'm still on page 1? And I also see that I can type whatever I wish in after the func=????????? and I don't even get an error message; just displaying the first page..

 

Kreg,

 

Terje.

Link to comment
Share on other sites

How are you retrieving the data from the URL in the index.php. Where's your code to trigger the function?

Example:

If ($_GET['func'])
{
    switch($_GET['func'])
     {
        case 'DisplayPlaces' : DisplayPlaces();
        Break; 
         .......................
      }
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.