echo href to pass two variables

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jamiebond
Forum Newbie
Posts: 2
Joined: Wed Apr 09, 2014 3:42 am

echo href to pass two variables

Post by jamiebond »

Hello, please help.

In a table column I have the following, which works as expected:

Code: Select all

echo "<td><a href = detail_edit.php?id1=".$fldID1." >"."EDIT"."</a></td>";
What I'm asking is; how to redirect to the detail page with TWO id variables:

Example: detail_edit.php?id1=23 AND id2=17

I know it has to be for example : ../detail_edit.php?fldID1=23&fldID2=17,

but I don't know how to include that "&fldID2" section in the php echo code.

I keep messing up the placement of the inverted commas (") and the full stops (.) in the echo.

Please help a newbie.

Thank you kindly.
Jamie.
pbs
Forum Contributor
Posts: 230
Joined: Fri Nov 07, 2008 5:31 am
Location: Nashik, India
Contact:

Re: echo href to pass two variables

Post by pbs »

Use like this

Code: Select all

echo '<td><a href="detail_edit.php?id1='.$fldID1.'&id2='.$fldID2.'">EDIT</a></td>';
jamiebond
Forum Newbie
Posts: 2
Joined: Wed Apr 09, 2014 3:42 am

Re: echo href to pass two variables

Post by jamiebond »

pbs wrote:Use like this

Code: Select all

echo '<td><a href="detail_edit.php?id1='.$fldID1.'&id2='.$fldID2.'">EDIT</a></td>';
Awesome.

When to use " and ' and the . tags is what gets me every time. Still learning.

Thank you very much.
Jamie.
pbs
Forum Contributor
Posts: 230
Joined: Fri Nov 07, 2008 5:31 am
Location: Nashik, India
Contact:

Re: echo href to pass two variables

Post by pbs »

jamiebond wrote:
pbs wrote:Use like this

Code: Select all

echo '<td><a href="detail_edit.php?id1='.$fldID1.'&id2='.$fldID2.'">EDIT</a></td>';
Awesome.

When to use " and ' and the . tags is what gets me every time. Still learning.

Thank you very much.
Jamie.
You are welcome
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: echo href to pass two variables

Post by pickle »

Use ' when you have a simple text string.
Use " when you have a text string with a variable in it you would like evaluated before output:

Code: Select all

$age = 30;
echo "My age is $age";

// will output:  My age is 30
. is the concatenation operator.

Actually, your string can be output with only one set of quotes:

Code: Select all

echo "<td><a href='detail_edit.php?id1=$fldID1&id2=$fldID2'">EDIT</a></td>";
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Post Reply