Code that enables me to update a blog PHP SQL

  mysqli, php, sql, sql-server

Basically, I need to write code that allows me to update (edit) posts that belong to the same ID as Post.ID.

Example : Login: [email protected] Pass: $#$#$ Login successful !!

As soon as someone logs in, they’re redirected to my index, where all the posts they’ve made are shown, along with the time they were created, the time they were updated, and the name of the person who posted, as you can see in the image.

enter image description here

In the upper right corner, I must code an "Update" button, as long as the post was made by "me", by the user in question. I made some code, but the button not even appears.

  {foreach item=post from=$posts}
  <div class="boxed">
    <div class="container p-1 my-1" style="text-align:center;">
      {if $post.user_id == $id_value}
        <div class="col-sm-12" style="text-align:right;">
          <a href="blog.php?micropost_id={$post.post_id}"
            <button type="button" class="btn btn-sm">update blog</button>
          </a>
        </div>
      {/if}
      <h4 style="color:purple">{$post.name}</h4>
      <h5 style="color:black">{$post.content}</h5>
      <p style="color:white">
      <div style="color:purple"class="row">
        <div class="col-sm-6" style="text-align:right;">updated: {$post.updated_at}</div>
        <div class="col-sm-6" style="text-align:left;">created: {$post.created_at}</div>
      </div>
    </div>
  </div>
  <p>
  {/foreach}
</body>
</html>

This code is part of my index, where I can display all posts already made, and as you can see, I’m trying to make a button, but it doesn’t appear .

Source: Ask PHP

LEAVE A COMMENT