Fresca Chanel
Fresca Chanel

Reputation: 15

How to use a php variable in html a href code?

I have a variable named $previousStep which I want to incorporate into my html a href link.

$previousStep=$myStep-1;
?>
<A HREF="http://localhost/hello.php?step='$previousStep'"><IMG BORDER="0" IMG STYLE  = "position:absolute; LEFT:400px; WIDTH:70px; HEIGHT:70px"    SRC="IMG_8854.jpg"></A>
<?php

How would I add this variable in?

Upvotes: 1

Views: 99

Answers (1)

iurii_n
iurii_n

Reputation: 1370

use <? echo $previousStep; ?> for output PHP data.

<a href="http://localhost/action?step=<?php echo $previousStep; ?>">Link</a>

Upvotes: 1

Related Questions