A string looks like this:
<form id="unban" method="post" action="unban.php?uid=<? echo $uID; ?>">
<input type="hidden" name="name" value="" />
<a onclick="document.getElementById('unban').submit();">UnBan</a>
</form>
And i need this to be echoed out with a load of other variables (as there are if statements so i cant just put it outisde php tags) however I cant find a way to store it in a variable and use it in the echo. My echo looks like:
echo "<tr><td>" . $row['username'] . "</td><td>" . $banBool . "</td><td>". $status ."</td><td>" . $row['full_name'] . "</td></tr>";
where $status would be the form above depending on an if statement.
Is there a way to hold it as a string and still do this?
Also, just to clarify the javascript syntax requires ‘target’ and doesnt allow “target”
You can write normal HTML within a PHP if-block – just close and re-open the PHP tags:
If you really need to hold it in a string, just make sure to escape whichever type of quotes are holding the string by adding a backslash before each one:
(Also notice you can’t do an echo within a variable – just concatenate the string with the variable)