Home>


I'm creating a simple word-of-mouth site based on php, and I am currently working on creating an admin page that allows me to edit and delete posts.
(Data is saved on MySQL, and login, new registration, new posting, and home page have already been created.)

When creating an administrator page, post content data is arranged there, and a delete/edit button is implemented for each post, and pressing that button opens each page for deletion/editing. I want to shape it.

○ Error message
I am planning to implement an edit button for each post, and when I open the edit page, I want to put the contents of the post in the text box using the value in the text box. Can I enter the data for the edited button?

○ Applicable source code

~~~

$id = $row ['id'];
echo "

\ ">
"." ". $row ['id']. '
';

if (empty (($_ POST ['edit'])&&($_ POST ['nolook'])))) {
echo $_POST ['nolook'];
}
?>

○ Tried
I tried to put the id of the data with hidden in the edit button form on the admin page, but I can't get the hidden value. (It seems that the value is something.)
I want to specify the data to be displayed on the edit page with the hidden value. (So ​​it is not necessary to display the hidden value on this page, but the following if statement is written to confirm what is in the value.)

I'd like you to tell me how to do it now or using ~ .

  • Answer # 1

    For simplicity, a single php does not serve both for display and editing.
    It is easier to debug if you make them separately.

    The code shown isn't a pin, but
    For example, you can write:

    foreach ($results as $row) {
        echo<<
        
        {$row ['id']}
    EOT;     if (empty (($_ POST ['edit'])&&($_POST ['nolook'])))) {         echo $_POST ['nolook'];     } } ?>

    PHP: Strings-in Manual
    Using "here document syntax",
    Nested with single and double quotations, it can be neatly confused.
    In the example shown, the part until EOT appears is echoed as it is.
    The php variable enclosed by {~} is expanded.
    It is useful when you want to output html code with this structure.