0

I have form, which builds a rather large output setup in various elements, based on how the form is filled out. I can post the whole code, but i think this makes it easier to understand, what I am trying to do.

Let's say I have form, with one input text field called 'notes'.

In this example, we pretend i have entered "Hello World!" in 'notes'.

When the form is posted, the value entered into 'notes' is echoed within some elements:

            <?php

            echo '<div class="bon" id="bon">';

            if (empty($_POST['notes'])) {
            // Echo nothing
            } else {
            echo '<div class="bonHr"></div>';
            echo '<div class="bonField">';
            echo '<span>' . nl2br($_POST['notes']) . '</span>';
            echo '</div>';
            }

            echo '</div>';

            ?>

And that is fine. Now I want to store the value in mySQL - I know how to do that. Problem is I want to store the value including the elements around it, into a mysql textfield.

So what I really want to store is everything the contains, in this case:

            <div class="bon" id="bon">
            <div class="bonHr"></div>
            <div class="bonField">
            <span>Hello World!</span>
            </div>
            </div>

How can I do this??

The reason why I need to do this, is that the output varies alot. So please help me to figure out how I can take a "dump" of the output, and throw it into mySQL...

4

1 に答える 1

0

Just store your output in variable show it and save in database.

<?php
$output = "";
$output .= '<div class="bon" id="bon">';

if (empty($_POST['notes'])) {
// Echo nothing
} else {
$output .= '<div class="bonHr"></div>';
$output .= '<div class="bonField">';
$output .= '<span>' . nl2br($_POST['notes']) . '</span>';
$output .= '</div>';
}

$output .= '</div>';
echo $output;

//Save output to database

?>
于 2012-06-06T14:04:43.357 に答える