php - INSERT / UPDATE Mysql Single Form -


i have 2 database tables

tbl1 users ---------- tbl2 gamesystems
uid field ------------- gs_uid field

the 2 tables tied user_id..

now want tbl2 updated able , fields not required.. exception of gs_uid when update there system.

my issue need insert user_id gs_uid.

function game_system() {        if(isset($_post['game_system'])) {               $user_id = $_session['uid'];             $motherboard = escape($_post['motherboard']);             $processor = escape($_post['processor']);                         $memory = escape($_post['memory']);             $graphics = escape($_post['graphics']);             $harddrive = escape($_post['harddrive']);             $power = escape($_post['powersupply']);             $cooling = escape($_post['cooling']);             $towercase = escape($_post['towercase']);               $sql = "insert gamesystem(gs_uid, motherboard, processor, memory, graphics, harddrive, powersupply, cooling, towercase) ";             $sql .= "values('{$user_id}','{$motherboard}','{$processor}','{$memory}','{$graphics}','{$harddrive}','{$power}','{$cooling}','{$towercase}') ";             $result = query($sql);              }    } 

if gs_uid primary key of table 'gamesystem' , field should not accept empty data.

otherwise, if gs_uid not key, what's primary key of table? in case of update, you'll need specify row you'd update, otherwise system not know how so.

the sql should looks below

update "gamesystem" set "gs_uid" = $user_id your_primary_key_column = specific value; 

Comments

Popular posts from this blog

unity3d - Rotate an object to face an opposite direction -

angular - Is it possible to get native element for formControl? -

javascript - Why jQuery Select box change event is now working? -