javascript - Edit specific record that inside php looped -


at moment i've coded out

<div class="row">  <div class="col-lg-12">   <table id="usertable" class="table table-bordered table-hover text-center">    <thead>     <th class="col-lg-1 text-center">user id</th>     <th class="col-lg-4 text-center">username</th>     <th class="col-lg-4 text-center">password</th>     <th class="col-lg-2 text-center">role</th>    </thead>    <tbody>    <?php     require('dbconnectmssql.php');     $sql = "select [user_id],[user_decoded],[pass_decoded],[permission] [rfttest].[dbo].[users]";     $query = sqlsrv_query ($conn , $sql);     if($query === false)     {die( print_r( sqlsrv_errors(), true));}     while($row = sqlsrv_fetch_array( $query, sqlsrv_fetch_numeric))     {      echo "<tr>";      foreach($row $x => $a)      {       echo "<td>".$a."</td>";      }       echo "<td>";       echo "<a href='#' ><span class='glyphicon glyphicon-wrench' aria-hidden='true'></span></a>";       echo "<a href='usercontrol.php?del=$row[0]'>";       echo "<span class='glyphicon glyphicon-trash' aria-hidden='true'></span>";       echo "</a>";       echo "</td>";       echo "</tr>";      }      ?>     </tbody>    /table>   </div>  </div> 

it's query out , show how many user in table.

  • i've done delete-record link php file , $_get data (maybe improve later if have solution suggest )

another things want is

  • edit specific record without redirected page

my idea right hidden form popup after click edit such i've click form pop data record stored , user can edit , save submit php file , redirect page

something : contain form within bootstrap popover? post

<a href="#" id="popover">the popover link</a> <div id="popover-head" class="hide">   title </div> <div id="popover-content" class="hide">   <!-- myform --> </div> 

but still can't figured out

  • how can code out make link open specific popover-head/content maybe popover-head/content must contain in id or ?
  • what php
  • what js/jq also

any solution want edit specific record echo out

sorry bad english

thanks

you want use ajax this.

this looks painful me - , if worked google spidering delete users on page:

}   echo "<td>";   echo "<a href='#' ><span class='glyphicon glyphicon-wrench' aria-hidden='true'></span></a>";   echo "<a href='usercontrol.php?del=$row[0]'>";   echo "<span class='glyphicon glyphicon-trash' aria-hidden='true'></span>";   echo "</a>";   echo "</td>";   echo "</tr>";  } 

it written

} ?>  <td>  <a href='#' ><span class='glyphicon glyphicon-wrench' aria-hidden='true'></span></a>  <a class="del" href='#' data-userid='<?php echo row["user_id"]; ?>'>  <span class='glyphicon glyphicon-trash' aria-hidden='true'></span>  </a> </td> </tr> <?php } ?> 

and

$(function() {   $(".del").on("click",function(e) {     e.preventdefault(); stop page reloading     var id=$(this).data("userid");     $.get("usercontrol.php?del="+id,function() {       alert(id + "deleted");     });   }); }); 

to edit

  • popup form data using .show() , .hide()
  • change data
  • ajax changes on submit - sure use preventdefault stop actual submission $("form").on("submit",function(e) { e.preventdefault(); $.post("save.php",$(this).serialize(),function(data) { alert("saved"); $("#formdiv").hide() });});
  • show result
  • close popup

Comments

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -