简体   繁体   中英

including html tag in a php code, specifically dealing with href function inside a php block

enter the html code once a condition is satisfied but then i aim to use php values and html tags together.

tried tag etc and got most of the part in running just unable to deal with href beacuse it is referencing to some values. not sure where to use "" or ``.

<?php.....        
echo `<a href="limitdatabase.php?Dropdown=.$_GET[Dropdown].;&search= $search_name;&wise=$_GET[wise];">Yes</a>`;

?> 

"yes" should work as a hyperlink but at the moment the php values are not processed that`s why no result.

You are using wrong sequence of quote

<?php

  ...

?>

<?php
  echo '<a href="limitdatabase.php?Dropdown=' .
         $_GET['Dropdown'].
         ';&search='. 
         $search_name .
         ';&wise='.
         $_GET['wise'].
         ';">Yes</a>';

?>

and you should use single quote and not backtics for string

You are using incorrect concatenation. Whenever you want to add any PHP variable then you need to close the braces and need to start after PHP variable as below:

<?php 
echo '<a href="limitdatabase.php?Dropdown='.$_GET['Dropdown'].'&search= '.$search_name.'&wise='.$_GET['wise'].'">Yes</a>';
?>

Also you should wrap Dropdown and wise in braces as it will not work directly in get as you have used. Hope it helps you!

You can use combination of html with php inside:

<a href="limitdatabase.php?Dropdown=<?PHP echo $_GET[Dropdown] . "&search=" 
 . $search_name . "&wise=" . $_GET[wise]; ?>">Yes</a>

Also, you can input whole link in string:

<?php
$mylink = "limitdatabase.php?Dropdown=" . $_GET[Dropdown] . "&search=" . $search_name . "&wise=" . $_GET[wise];
?>
<a href="<?PHP echo $mylink; ?>">YES</a>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM