how to create a join feature in php with a mySQL database -


hello im new php scenario this:

i have created login/logout feature , event page, on event page, there join button next each event.

i want decrease int value (expected number of people) in mysql database when user clicks join button.

how go doing this? problem not know how associate each button corresponding event.

the events dynamically created other users.

the following javascript within tags

$("button").click(function() {             var id = $(this).attr('id');              var request = $.ajax({                 url: "decrease.php",                 method: "post",                 data: { id : id },              });              request.done(function( msg ) {                 $( "#log" ).html( msg );             });              request.fail(function( jqxhr, textstatus ) {                 alert( "request failed: " + textstatus );             });         });     }); 

the following file decrease.php:

define('db_server', "localhost"); define('db_user', "root"); define('db_password', ""); define('db_table', "bong");  $mysqli = mysqli_connect(db_server, db_user, db_password, db_table);  if (mysqli_connect_errno($mysqli)) {     trigger_error('database connection failed: '  . mysqli_connect_error(), e_user_error); }   if(isset($_post['id'])) {     //$id = $_post['id'];     $id = $_request["id"];  }  $mysqli->query("update `events` set `eppl` = `eppl` - 1 `eid` = '$id'"); 

what can put data-field of event id like

<div class="formgroup">         <div data-id='26'><!-- of event --></div>     <button>join</button> </div> 

now every join click can parse data-id of related div (for eg. previous div or same parent child div) id further process.


Comments

Popular posts from this blog

html - Firefox flex bug applied to buttons? -

html - Missing border-right in select on Firefox -

c# - two queries in same method -