简体   繁体   中英

How to increase a value of PHP Variable without page refresh on click event

The name attribute in input field need to be updated dynamically. The form is being submitted through ajax request and db gets new value, which need to be taken as count increment without page refresh(to save the motive ajax form submit), How can i increase the PHP count variable..

  • I cannot rule out below code coz on first page refresh or any page refresh event it should get the updated value form db,

Will jquery help out and how or some other better method are in your hand.

<?PHP
    $sql=sql::readOne("SELECT col_name FROM table_name");
    $sql=json_decode($sql->col_name,true);
    $count= count($sql);
?>

HTML CODE PART

 </form>
        ..... 
        <input class="form-control" name="col_name[<?php echo $count+1 ?>][username]" placeholder="User Name" type="text" id="username" value="" >
  <input class="form-control" name="col_name[<?php echo $count+1 ?>][email]" placeholder="email" type="text" id="email" value="" >
        .....
        <button type="submit"  id="editdata" class="btn btn-success">Edit and Update </button>
    </form>

在php递增变量后,应立即使用ajax更新数据库,以便在页面重新加载时,它会在数据库中获得递增的值。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM