0

I have to insert some data when I press the insert button to the database and I want to see each row then after one 0.5 sec the div will disappeare. I know the code is wrong is just for example to understand.

    <?php

    $contents = file_get_contents("foo.txt.001");
    $pollfields = explode(',', $contents);

    foreach ($pollfields as $key) {

                $sql = "INSERT INTO keywords (`keys`) VALUES ('".$key."')";
                if ($conn->query($sql) === TRUE) {

 <div v-if="show" transition="fade" >
        <div class="alert alert-success" role="alert">
         <strong>$key</strong>
     </div>
    </div>
                echo ;
            } else {
                echo "Error: " . $sql . "<br>" . $conn->error;
            }
    }

    ?>
<script> new Vue({ el: '#demo', data: { show: true } }) </script>

and this css:

.fade-enter-active, .fade-leave-active {
  transition: opacity .5s
}
.fade-enter, .fade-leave-to /* .fade-leave-active below version 2.1.8 */     {
  opacity: 0
}
Sᴀᴍ Onᴇᴌᴀ
  • 8,218
  • 8
  • 36
  • 58
  • 1
    Your code is vulnerable to [**SQL injection**](https://en.wikipedia.org/wiki/SQL_injection) attacks. You should use prepared statements with bound parameters, via either the [**mysqli**](https://secure.php.net/manual/en/mysqli.prepare.php) or [**PDO**](https://secure.php.net/manual/en/pdo.prepared-statements.php) drivers. [**This post**](https://stackoverflow.com/questions/60174/how-can-i-prevent-sql-injection-in-php) has some good examples. – Alex Howansky Jul 25 '17 at 17:20
  • i know but how i fade the div lol in vue i want to apper the disapper 0.5 sec later – Adrian Prime Jul 25 '17 at 17:22
  • Where's your vue code? – apokryfos Jul 25 '17 at 17:26
  • – Adrian Prime Jul 25 '17 at 17:35

2 Answers2

2

You need to use the animation element like so:

<transition name="fade">
    <div v-if="show">
     // content to be animated
    </div>
</transition>

https://jsbin.com/laxoqo/edit?html,js,output

Helder Lucas
  • 3,273
  • 2
  • 21
  • 26
-6

Use jQuery, it has some great built in features for this.

$('#id').fadeOut()

ought to do the trick. You can download jquery here.

Sᴀᴍ Onᴇᴌᴀ
  • 8,218
  • 8
  • 36
  • 58