0

little help here please....I was writing a php script for a message system. comments are displayed in php with the use of $comments through a function. I was trying to use a light box in javascript, so that user will have the option to delete each comment. How can I combine the following php script with the javascript code:

<?php

$comments .= " <font size='3'>   ?>

<a href = "javascript:void(0)" onclick = "document.getElementById('light').style.display='block';document.getElementById('fade').style.display='block'">**Delete**</a>
    <div id="light" class="white_content">

        <form action="<?php=$_SERVER['PHP_SELF'];?>" method="post">
        <input type="submit" name="submit_1" value="Delete Photo" >
        </form>

    <a href = "javascript:void(0)" onclick = "document.getElementById('light').style.display='none';document.getElementById('fade').style.display='none'"><button>&nbsp;&nbsp;&nbsp;&nbsp;Cancel&nbsp;&nbsp;&nbsp;&nbsp;</button></a></div>
    <div id="fade" class="black_overlay"></div>             




<?php  $comments .= "</font>"; ?>

2 Answers 2

1
<?php
$comments .= <<<EOD
<font size='3'>
<a href="javascript:void(0)" onclick="document.getElementById('light').style.display='block';document.getElementById('fade').style.display='block'">**Delete**</a>
    <div id="light" class="white_content">
        <form action="$_SERVER[PHP_SELF]" method="post">
        <input type="submit" name="submit_1" value="Delete Photo" >
        </form>

        <a href="javascript:void(0)" onclick="document.getElementById('light').style.display='none';document.getElementById('fade').style.display='none'"><button>&nbsp;&nbsp;&nbsp;&nbsp;Cancel&nbsp;&nbsp;&nbsp;&nbsp;</button></a>
    </div>
    <div id="fade" class="black_overlay"></div>             
</font>
EOD;
?>

Something like that should work. Remember that the "EOD;" needs to be on it's own, at the very beginning of a line.

See also http://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc

You're trying to use the "?> html... " construct incorrectly. It doesn't "return" the string, it prints it out directly - it will get sent to the browser whenever the parser passes over it, rather than being added to $comments

Sign up to request clarification or add additional context in comments.

Comments

1

There are two syntax errors:

1, You're missing the closing double quotes from line 3:

$comments .= " <font size='3'> "

2, <?php= is invalid and should be used as:

<?php echo or <?= (shorthand echo statements must be enabled to use <?=)

here: <form action="<?=$_SERVER['PHP_SELF'];?>" method="post">

If you're looking to make your entire block of code 1 string then i would recommend using a heredoc statement like:

<?php

$comments .= <<<EOD
    <font size="3">
        <a href = "javascript:void(0)" onclick = "document.getElementById('light').style.display='block';document.getElementById('fade').style.display='block'">**Delete**</a>
        <div id="light" class="white_content">
            <form action="{$_SERVER['PHP_SELF']}" method="post">
                <input type="submit" name="submit_1" value="Delete Photo" >
            </form>
            <a href = "javascript:void(0)" onclick = "document.getElementById('light').style.display='none';document.getElementById('fade').style.display='none'"><button>&nbsp;&nbsp;&nbsp;&nbsp;Cancel&nbsp;&nbsp;&nbsp;&nbsp;</button></a>
        </div>
        <div id="fade" class="black_overlay"></div>
    </font>
EOD;

?>

1 Comment

did it...still nothing

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.