Indicate the newly added user with different color or symbol or div highlighting









up vote
0
down vote

favorite












I want to indicate the currently newly added user through symbol or unique color, like when someone click on Save and the user that is added should be shown in a different color or highlighted at that glimpse and then disappear after refresh, something like what the stackoverflow does in commenting system.



This is my code of index.php in this page I'v form and after submitting this form I' added the user to the database and then I'v shown them in descending order



 <form action="save.php" method="post">
<div class="text-center" id='input_tag'>
<input type="text" name="name" id= 'input'>
<input type="submit" name="submit" class="btn btn-dark " id = "button" value="Save">
</div>
</form>
<div class="container">
<div class="row">

<div class="col-md-4">
<table width="100" class="table" id = 'tb'>
<?php
$connect = mysqli_connect('localhost','root','root','user');
$query = "SELECT name from userdata order by id DESC";

$run = mysqli_query($connect,$query);


while($row = mysqli_fetch_array($run))


echo "<tr>";
echo "<td>".$row['name']."<td>";
echo "</tr>";





?>


</table>
</div>


</div>
</div>


This is save.php where the user are added to DB and then redirected to the index.php page



$connect = mysqli_connect('localhost', 'root' ,'root' ,'user');

if($connect)
if(isset($_POST['submit']))

$name = $_POST['name'];
$query = "INSERT INTO `userdata`(`name`) values ('$name')";

if(mysqli_query($connect,$query))
header('location:index.php');





else
echo "not connected";










share|improve this question























  • Please update your question and list all the columns in your database table. What is the primary key?
    – ryantxr
    Nov 10 at 6:53














up vote
0
down vote

favorite












I want to indicate the currently newly added user through symbol or unique color, like when someone click on Save and the user that is added should be shown in a different color or highlighted at that glimpse and then disappear after refresh, something like what the stackoverflow does in commenting system.



This is my code of index.php in this page I'v form and after submitting this form I' added the user to the database and then I'v shown them in descending order



 <form action="save.php" method="post">
<div class="text-center" id='input_tag'>
<input type="text" name="name" id= 'input'>
<input type="submit" name="submit" class="btn btn-dark " id = "button" value="Save">
</div>
</form>
<div class="container">
<div class="row">

<div class="col-md-4">
<table width="100" class="table" id = 'tb'>
<?php
$connect = mysqli_connect('localhost','root','root','user');
$query = "SELECT name from userdata order by id DESC";

$run = mysqli_query($connect,$query);


while($row = mysqli_fetch_array($run))


echo "<tr>";
echo "<td>".$row['name']."<td>";
echo "</tr>";





?>


</table>
</div>


</div>
</div>


This is save.php where the user are added to DB and then redirected to the index.php page



$connect = mysqli_connect('localhost', 'root' ,'root' ,'user');

if($connect)
if(isset($_POST['submit']))

$name = $_POST['name'];
$query = "INSERT INTO `userdata`(`name`) values ('$name')";

if(mysqli_query($connect,$query))
header('location:index.php');





else
echo "not connected";










share|improve this question























  • Please update your question and list all the columns in your database table. What is the primary key?
    – ryantxr
    Nov 10 at 6:53












up vote
0
down vote

favorite









up vote
0
down vote

favorite











I want to indicate the currently newly added user through symbol or unique color, like when someone click on Save and the user that is added should be shown in a different color or highlighted at that glimpse and then disappear after refresh, something like what the stackoverflow does in commenting system.



This is my code of index.php in this page I'v form and after submitting this form I' added the user to the database and then I'v shown them in descending order



 <form action="save.php" method="post">
<div class="text-center" id='input_tag'>
<input type="text" name="name" id= 'input'>
<input type="submit" name="submit" class="btn btn-dark " id = "button" value="Save">
</div>
</form>
<div class="container">
<div class="row">

<div class="col-md-4">
<table width="100" class="table" id = 'tb'>
<?php
$connect = mysqli_connect('localhost','root','root','user');
$query = "SELECT name from userdata order by id DESC";

$run = mysqli_query($connect,$query);


while($row = mysqli_fetch_array($run))


echo "<tr>";
echo "<td>".$row['name']."<td>";
echo "</tr>";





?>


</table>
</div>


</div>
</div>


This is save.php where the user are added to DB and then redirected to the index.php page



$connect = mysqli_connect('localhost', 'root' ,'root' ,'user');

if($connect)
if(isset($_POST['submit']))

$name = $_POST['name'];
$query = "INSERT INTO `userdata`(`name`) values ('$name')";

if(mysqli_query($connect,$query))
header('location:index.php');





else
echo "not connected";










share|improve this question















I want to indicate the currently newly added user through symbol or unique color, like when someone click on Save and the user that is added should be shown in a different color or highlighted at that glimpse and then disappear after refresh, something like what the stackoverflow does in commenting system.



This is my code of index.php in this page I'v form and after submitting this form I' added the user to the database and then I'v shown them in descending order



 <form action="save.php" method="post">
<div class="text-center" id='input_tag'>
<input type="text" name="name" id= 'input'>
<input type="submit" name="submit" class="btn btn-dark " id = "button" value="Save">
</div>
</form>
<div class="container">
<div class="row">

<div class="col-md-4">
<table width="100" class="table" id = 'tb'>
<?php
$connect = mysqli_connect('localhost','root','root','user');
$query = "SELECT name from userdata order by id DESC";

$run = mysqli_query($connect,$query);


while($row = mysqli_fetch_array($run))


echo "<tr>";
echo "<td>".$row['name']."<td>";
echo "</tr>";





?>


</table>
</div>


</div>
</div>


This is save.php where the user are added to DB and then redirected to the index.php page



$connect = mysqli_connect('localhost', 'root' ,'root' ,'user');

if($connect)
if(isset($_POST['submit']))

$name = $_POST['name'];
$query = "INSERT INTO `userdata`(`name`) values ('$name')";

if(mysqli_query($connect,$query))
header('location:index.php');





else
echo "not connected";







php forms






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 10 at 6:39

























asked Nov 10 at 6:05









Khan

136




136











  • Please update your question and list all the columns in your database table. What is the primary key?
    – ryantxr
    Nov 10 at 6:53
















  • Please update your question and list all the columns in your database table. What is the primary key?
    – ryantxr
    Nov 10 at 6:53















Please update your question and list all the columns in your database table. What is the primary key?
– ryantxr
Nov 10 at 6:53




Please update your question and list all the columns in your database table. What is the primary key?
– ryantxr
Nov 10 at 6:53












2 Answers
2






active

oldest

votes

















up vote
0
down vote













You can achieve this with simple CSS and JS.



Change the header function in save.php to



header('location:index.php?added=1');


Add CSS style to index.php



<style type="text/css">
tr:last-of-type
transition: .7s background;

</style>


At the end of index.php add the following



 <?php
if (isset($_GET['added']))
print '<script type="text/javascript">

document.querySelector("tr:first-of-type").style.background = "red";
setTimeout(function() document.querySelector("tr:first-of-type").style.background = unset",2000);
</script>';



?>


I'm assuming that the new user is going to be displayed at first.






share|improve this answer





























    up vote
    0
    down vote













    If you want to display the user differently the first time, then you will need
    some sort of flag that says if the user has been shown yet or not.
    At the time you insert the user, set the didShow flag to false.
    When you show the user, check the flag and if false, show the user
    with the symbol and set the didShow flag to true.
    When you show the user, if the didShow flag is false, show the
    user without the symbol.



    Add a new column named didShow to your database. Set it to default to 0 (false).



    Change the query like this:



    $query = "SELECT id, name, didShow from userdata order by id DESC";


    In the loop, use different formatting and update the rows that have to be updated.



    $run = mysqli_query($connect, $query);
    $style = 'style="color:#ccc"';
    while($row = mysqli_fetch_array($run))

    echo "<tr>";
    if ( $row['didShow'] == 0 )
    echo "<td><span $style>".$row['name']."</span><td>";
    $updateQuery = "UPDATE `userdata` SET didShow=1 WHERE id = $row['id']";
    mysqli_query($connect, $updateQuery);
    else
    echo "<td>".$row['name']."<td>";

    echo "</tr>";







    share|improve this answer




















      Your Answer






      StackExchange.ifUsing("editor", function ()
      StackExchange.using("externalEditor", function ()
      StackExchange.using("snippets", function ()
      StackExchange.snippets.init();
      );
      );
      , "code-snippets");

      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "1"
      ;
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function()
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled)
      StackExchange.using("snippets", function()
      createEditor();
      );

      else
      createEditor();

      );

      function createEditor()
      StackExchange.prepareEditor(
      heartbeatType: 'answer',
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader:
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      ,
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );













      draft saved

      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53236435%2findicate-the-newly-added-user-with-different-color-or-symbol-or-div-highlighting%23new-answer', 'question_page');

      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes








      up vote
      0
      down vote













      You can achieve this with simple CSS and JS.



      Change the header function in save.php to



      header('location:index.php?added=1');


      Add CSS style to index.php



      <style type="text/css">
      tr:last-of-type
      transition: .7s background;

      </style>


      At the end of index.php add the following



       <?php
      if (isset($_GET['added']))
      print '<script type="text/javascript">

      document.querySelector("tr:first-of-type").style.background = "red";
      setTimeout(function() document.querySelector("tr:first-of-type").style.background = unset",2000);
      </script>';



      ?>


      I'm assuming that the new user is going to be displayed at first.






      share|improve this answer


























        up vote
        0
        down vote













        You can achieve this with simple CSS and JS.



        Change the header function in save.php to



        header('location:index.php?added=1');


        Add CSS style to index.php



        <style type="text/css">
        tr:last-of-type
        transition: .7s background;

        </style>


        At the end of index.php add the following



         <?php
        if (isset($_GET['added']))
        print '<script type="text/javascript">

        document.querySelector("tr:first-of-type").style.background = "red";
        setTimeout(function() document.querySelector("tr:first-of-type").style.background = unset",2000);
        </script>';



        ?>


        I'm assuming that the new user is going to be displayed at first.






        share|improve this answer
























          up vote
          0
          down vote










          up vote
          0
          down vote









          You can achieve this with simple CSS and JS.



          Change the header function in save.php to



          header('location:index.php?added=1');


          Add CSS style to index.php



          <style type="text/css">
          tr:last-of-type
          transition: .7s background;

          </style>


          At the end of index.php add the following



           <?php
          if (isset($_GET['added']))
          print '<script type="text/javascript">

          document.querySelector("tr:first-of-type").style.background = "red";
          setTimeout(function() document.querySelector("tr:first-of-type").style.background = unset",2000);
          </script>';



          ?>


          I'm assuming that the new user is going to be displayed at first.






          share|improve this answer














          You can achieve this with simple CSS and JS.



          Change the header function in save.php to



          header('location:index.php?added=1');


          Add CSS style to index.php



          <style type="text/css">
          tr:last-of-type
          transition: .7s background;

          </style>


          At the end of index.php add the following



           <?php
          if (isset($_GET['added']))
          print '<script type="text/javascript">

          document.querySelector("tr:first-of-type").style.background = "red";
          setTimeout(function() document.querySelector("tr:first-of-type").style.background = unset",2000);
          </script>';



          ?>


          I'm assuming that the new user is going to be displayed at first.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 10 at 7:07

























          answered Nov 10 at 6:54









          Doni

          13




          13






















              up vote
              0
              down vote













              If you want to display the user differently the first time, then you will need
              some sort of flag that says if the user has been shown yet or not.
              At the time you insert the user, set the didShow flag to false.
              When you show the user, check the flag and if false, show the user
              with the symbol and set the didShow flag to true.
              When you show the user, if the didShow flag is false, show the
              user without the symbol.



              Add a new column named didShow to your database. Set it to default to 0 (false).



              Change the query like this:



              $query = "SELECT id, name, didShow from userdata order by id DESC";


              In the loop, use different formatting and update the rows that have to be updated.



              $run = mysqli_query($connect, $query);
              $style = 'style="color:#ccc"';
              while($row = mysqli_fetch_array($run))

              echo "<tr>";
              if ( $row['didShow'] == 0 )
              echo "<td><span $style>".$row['name']."</span><td>";
              $updateQuery = "UPDATE `userdata` SET didShow=1 WHERE id = $row['id']";
              mysqli_query($connect, $updateQuery);
              else
              echo "<td>".$row['name']."<td>";

              echo "</tr>";







              share|improve this answer
























                up vote
                0
                down vote













                If you want to display the user differently the first time, then you will need
                some sort of flag that says if the user has been shown yet or not.
                At the time you insert the user, set the didShow flag to false.
                When you show the user, check the flag and if false, show the user
                with the symbol and set the didShow flag to true.
                When you show the user, if the didShow flag is false, show the
                user without the symbol.



                Add a new column named didShow to your database. Set it to default to 0 (false).



                Change the query like this:



                $query = "SELECT id, name, didShow from userdata order by id DESC";


                In the loop, use different formatting and update the rows that have to be updated.



                $run = mysqli_query($connect, $query);
                $style = 'style="color:#ccc"';
                while($row = mysqli_fetch_array($run))

                echo "<tr>";
                if ( $row['didShow'] == 0 )
                echo "<td><span $style>".$row['name']."</span><td>";
                $updateQuery = "UPDATE `userdata` SET didShow=1 WHERE id = $row['id']";
                mysqli_query($connect, $updateQuery);
                else
                echo "<td>".$row['name']."<td>";

                echo "</tr>";







                share|improve this answer






















                  up vote
                  0
                  down vote










                  up vote
                  0
                  down vote









                  If you want to display the user differently the first time, then you will need
                  some sort of flag that says if the user has been shown yet or not.
                  At the time you insert the user, set the didShow flag to false.
                  When you show the user, check the flag and if false, show the user
                  with the symbol and set the didShow flag to true.
                  When you show the user, if the didShow flag is false, show the
                  user without the symbol.



                  Add a new column named didShow to your database. Set it to default to 0 (false).



                  Change the query like this:



                  $query = "SELECT id, name, didShow from userdata order by id DESC";


                  In the loop, use different formatting and update the rows that have to be updated.



                  $run = mysqli_query($connect, $query);
                  $style = 'style="color:#ccc"';
                  while($row = mysqli_fetch_array($run))

                  echo "<tr>";
                  if ( $row['didShow'] == 0 )
                  echo "<td><span $style>".$row['name']."</span><td>";
                  $updateQuery = "UPDATE `userdata` SET didShow=1 WHERE id = $row['id']";
                  mysqli_query($connect, $updateQuery);
                  else
                  echo "<td>".$row['name']."<td>";

                  echo "</tr>";







                  share|improve this answer












                  If you want to display the user differently the first time, then you will need
                  some sort of flag that says if the user has been shown yet or not.
                  At the time you insert the user, set the didShow flag to false.
                  When you show the user, check the flag and if false, show the user
                  with the symbol and set the didShow flag to true.
                  When you show the user, if the didShow flag is false, show the
                  user without the symbol.



                  Add a new column named didShow to your database. Set it to default to 0 (false).



                  Change the query like this:



                  $query = "SELECT id, name, didShow from userdata order by id DESC";


                  In the loop, use different formatting and update the rows that have to be updated.



                  $run = mysqli_query($connect, $query);
                  $style = 'style="color:#ccc"';
                  while($row = mysqli_fetch_array($run))

                  echo "<tr>";
                  if ( $row['didShow'] == 0 )
                  echo "<td><span $style>".$row['name']."</span><td>";
                  $updateQuery = "UPDATE `userdata` SET didShow=1 WHERE id = $row['id']";
                  mysqli_query($connect, $updateQuery);
                  else
                  echo "<td>".$row['name']."<td>";

                  echo "</tr>";








                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Nov 10 at 7:14









                  ryantxr

                  2,6341520




                  2,6341520



























                      draft saved

                      draft discarded
















































                      Thanks for contributing an answer to Stack Overflow!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid


                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.

                      To learn more, see our tips on writing great answers.





                      Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                      Please pay close attention to the following guidance:


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid


                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.

                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53236435%2findicate-the-newly-added-user-with-different-color-or-symbol-or-div-highlighting%23new-answer', 'question_page');

                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      How to how show current date and time by default on contact form 7 in WordPress without taking input from user in datetimepicker

                      Syphilis

                      Darth Vader #20