Page 1 of 1

echo href to pass two variables

Posted: Wed Apr 09, 2014 3:47 am
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.

Re: echo href to pass two variables

Posted: Wed Apr 09, 2014 4:28 am
by pbs
Use like this

Code: Select all

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

Re: echo href to pass two variables

Posted: Wed Apr 09, 2014 5:06 am
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.

Re: echo href to pass two variables

Posted: Wed Apr 09, 2014 5:31 am
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

Re: echo href to pass two variables

Posted: Fri Apr 11, 2014 9:44 am
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>";