Multiple URL parameters? - php

I am using Dreamweaver and would like to add multiple parameters to my my link. Right now I have one parameter which works fine, but I would like to add multiple parameters to the same link, how do I do that?
The code to the link is as follows:
<a href="Patient.php?Patient=<?php echo
$row_Patienter['Patient']; ?>">Visa</a>
This does links to another page's Recordset.
My question is:
How do I add multiple parameters to the same link? How would it look like?

You can separate parameters by adding a & at the end of each parameter.
Something like:
http://www.domain.com?parameter1=value1&parameter2=value2
But in your case I would recommend to do it like this:
<?php
echo "<a href='patien.php?parameter1=".$value1."&parameter2=".$value2."'>Link</a>";
?>

You add extra parameters by starting with ? and adding & each time you start a new parameter. Remember in HTML to use &
Visa

<a href="bar.php?foo=<php echo $foo; ?>&bar=<?php echo $bar; ?>">
or whatever the values are. Better use echo, not sure what you wrote works

Related

Is it possible to add GET statements to a URL when submitting a form to self?

Is it possible to have a link submit to self with GET variables in it?
<a href='#?id=1234&c=2' data-toggle='modal' data-target='#mymodal'></a>
Then when clicked the URL would look like this -
example.com/test.php?msg=hello#?id=1234&c=2
But it doesn't work / PHP doesn't see any of the variables after the #.
I have the following code on the same page (for testing) -
echo $_GET['id'];
And I want it to echo 1234
Is there another way to do this?
Thanks!
If you want the query params you should put them before "#" and not after. When You put them after it, then your php script "won't see" them. Check out this answer on superuser for more.
Also your url example "example.com/test.php?msg=hello#?id=1234&c=2" has 2 "?" in it and it should not.

angularjs ng-click or ng-init? php variables

I'm new in angularjs and after looking in every site and forum without answer, somebody can help me to selve this?
i have this html with php code, and i want to pass php var into angularjs event.
<a ng-init="changeCat=<?php echo $id_cat, $category; ?>" id="cat_<?php echo $id_cat; ?>" class="cat-list" href="#"><?php echo $category->name; ?></a>
thanks in advance!
assuming you have a method changeCat() you can pass it php variables using something like ng-init="changeCat(<?php echo $id_cat; ?>)". I am assuming you want ng-int at this point but it should give you enough to get going with.
also try searching 'pass php to ng' or 'pass php variable to angular controller'... results should be similar.
EDIT:
As #Kevin B said you may want to change the way you are doing things but that said.
If you are to use more that one variabel then have a look at this:
Laravel/Angular: passing data within php page to angularjs

If get field with multiple values

I have an if statement involving a get field. However I would like it have an option of 2 different values.
This is what I currently have
<?php
if(get_field('more_links')):
?>
I would it like go if have more_links or exp_link or both do this. I know the below wont work but just to help show what I mean.
<?php
if(get_field('more_links, exp_link')):
?>
by default you need to call this function more than just once, if you want more than you param. You can call this like if(get_field('exp_link') && get_field('more_links')):, or you can create a wrapper that receives an array and call get_field foreach value on the parameter

Carry over arguments to new URL

I am working with some anchor tags in HTML where i need to carry over some arguments from the first url to the second url
My Link
My current URL is - oldpage.html?arg=value
But the "My Link" redirects to -
newpage.html
and not
newpage.html?arg=value
How do i carry over the value of arg ?
If you want to just copy a known variable over, it's as simple as
<?php echo "My Link" ?>
and then oldpage.html?arg=value would produce a link to newpage.html?arg=value.
However, if you want to pass over the entire query string, you can achieve this with the $_SERVER["QUERY_STRING"] variable.
<?php echo "My Link" ?>
This will propagate the entire query string to the new page. So if you accessed the current page with oldpage.html?arg=value&color=green, the link would point to newpage.html?arg=value&color=green.
Alternatively you could use http_build_query, allowing you to add extra parameters or modify the existing query string as you see fit.
<?php echo "My Link" ?>
Using this, navigating to the current page as oldpage.html?arg=value would produce a link to newpage.html?arg=value&foo=bar.
My Link
Or you could do this:
My Link
But that is only if your server allows you to use SERVER variables.

PHP: Pass a variable in URL via a clicked link

I created a function that requires one parameter to be passed into it but I need that parameter to come from another script. How do I embed the variable into a link then put that variable into the function in another script? I know I need to utilize $_GET, isset($_GET['']) and a href but I just can't put it all together.
$_GET is collection of of query string parameters. If you had a url like: test.php?param1=foo&param2=bar you can access foo by $_GET['param1'] etc..
Use $_REQUEST['something']
Your link must be:
Click Me
Inside test.php
if(#$_REQUEST['something']=="something"){
echo $_REQUEST['something1'];
}
When you click Click Me, test.php would echo "test".

Categories