Goutam Reddy
Goutam Reddy

Reputation: 23

how to insert same data in different table based on checkbox ? mysql php

I want to insert data in multiple table

I have two tables > recharge, due_user

recharge table has

>> ID - MOBno-  AMount - Network

due_user has

>> ID - userID - MOBno - Amount - NETWORK

in my form I have checkbox which will ask userID only if I click checkbox.

now insertion of data procedure would be .

if unchecked

 data > ID - mobno - Amount- Network 

will be inserted in Recharging table if checked

 data > ID-  userID -  mobile - amount - Network 

will go both table Recharge and Due_user table but user id will we goes into only due usertable

Upvotes: 1

Views: 210

Answers (1)

Bart
Bart

Reputation: 1268

Let's say your checkbox looks like this

<input type="checkbox" name="isUserId" />

Then in php

<?php
    //here goes your recharge table insert
    if(isset($_POST['isUserId'])){
        //and here due user table insert
    }
?>

Upvotes: 1

Related Questions