How do I pass more than one variable in a link. Here is what I have:

    $rows[] = array(t($points->name),
              t($points->tot_points),
              t($points->tot_games),
              t($points->avg_points),
              l(t(details), "poker/details_page/".$points->player_id)
);

The l line works and passes the variable $points->player_id to the function, but I can't figure out how to pass a second variable. Can someone tell me how?

Thanks in advance.

Norm

Comments

profix898’s picture

Append your vars with '?': page?x=abc&y=123
You must run urlencode on your vars before appending them to url:

$url = 'index.php?x='.urlencode($x).'&y='.urlencode($y);

To extract the variables from url use explode and urldecode.
Look at urldecode docu for example (http://php.net/urldecode).
What you do is:
- explode the QUERY_STRING by '&' to get the value pairs and
- explode each pair by '=' to seperate 'key = value'

Or simply use something like
'index.php?section=news&action=add'
and to extract the vars
$_GET['section'] with value 'news'
$_GET['action'] with value 'add'

I tried to post a more complete example, but Drupal.org didnt
like that :( Hope this helps.

npollock’s picture

This looks a lot more complicated than I thought it would be. I appreciate the info, now that I know what to look for in the code, I will start searching modules for sume drupal coding examples.

Thanks

Norm

profix898’s picture

What are you trying to do? Why do you need to pass multiple parameters?
When the 'destination' function is called from hook_menu you can
simply add the parameters seperated by '/'. The menu will then get
all after the matching part as parameters to the function. For example:

$items[] = array('path' => 'node/test',
 'title' => t('test'),
 'callback' => 'mytest',
 'type' => ...

When you call 'node/test/abc/123, you will have 'abc' and '123' in
the parameters. Look at this http://drupaldocs.org/api/head/function/page_example_baz

You could also use a global variables ... or store vars to database ...