473,325 Members | 2,792 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

How to insert session data in INSERT, SELECT sql

Help me plzz...

I insert data into pohonLatihan table from senarailatihan table. It done!!
But how can i insert the 'user id' that i capture from the 'session' into the same table.?

Expand|Select|Wrap|Line Numbers
  1.  $no_pekerja = $_SESSION['user_id'];
  2.  
  3. $id_latihan=$_GET['id_latihan'];
  4.  
  5.  
  6. $insert_query= "INSERT INTO pohonLatihan (namalatihan, tempat, t_mula, t_tamat, spesifikasi, jum_jam)
  7.         SELECT namalatihan,tempat,t_mula,t_tamat,spesifikasi, jum_jam 
  8.         FROM senarailatihan WHERE id_latihan='$id_latihan'";
Apr 28 '10 #1
2 5018
chathura86
227 100+
you can have the variable in the SELECT statement

assume that you have a user_id column and you want to insert $no_pekerja to that here how it does

Expand|Select|Wrap|Line Numbers
  1. $insert_query= INSERT INTO pohonLatihan (namalatihan, tempat, t_mula, t_tamat, spesifikasi, jum_jam, user_id)
  2. SELECT namalatihan,tempat,t_mula,t_tamat,spesifikasi, jum_jam, '$no_pekerja' 
  3. FROM senarailatihan WHERE id_latihan='$id_latihan'";
Apr 28 '10 #2
It works!! I'm just adjust...little bit more in coding..i'm really appreciate it!!!

**it look like this
Expand|Select|Wrap|Line Numbers
  1.  $no_pekerja = $_SESSION['user_id'];
  2.  
  3. $id_latihan=$_GET['id_latihan'];
  4.  
  5.  
  6. $insert_query= "INSERT INTO pohonLatihan (namalatihan, tempat, t_mula, t_tamat, spesifikasi, jum_jam, no_pekerja )
  7.         SELECT namalatihan,tempat,t_mula,t_tamat,spesifikasi, jum_jam,'$no_pekerja'
  8.         FROM senarailatihan WHERE id_latihan='$id_latihan'";
Apr 29 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Gansoinat | last post by:
Hi, During an insert command, i'm using @@IDENTIFIER to obtain the key (auto increment colonne). 4 users insert record in the same time. result : user1 : Key=1 user2 : Key=2 user3 : Key=2...
0
by: adove | last post by:
I am having problems with the following code. I am trying to update my db table Categories in Northwind. I have borrowed this code from www.dotnetjohn.com/articles/articleid27.aspx Although it...
4
by: Ross | last post by:
Hi, I want to run this query. The query runs fine but it always inserts blanks into the temp database. Any suggestions would be appreciated. DECLARE GLOBAL TEMPORARY TABLE temp_date (v_date...
0
by: Suler Abou | last post by:
Hi, I'm having a problem with an SQL statement, I have a statement that goes like this: "INSERT INTO table VALUES('TransID','CID',etc...);" it basically adds new data to a table. When the...
1
by: Joe | last post by:
Hello All, I am trying to insert a record in the MS Access DB and for some reason I cannot get rid of error message, System.Data.OleDb.OleDbException: Syntax error in INSERT INTO statement. ...
7
by: fintudet | last post by:
Hello. During some experimentation with DB2 decimal numbers representations, I have discovered very unexpected behaviour of the global temporary table. Consider this example. Such I had...
2
by: 4.spam | last post by:
Hello. v8.2. Is it possible? Example: --------------- create function t(v varchar(1)) modifies sql data returns table(c varchar(1))
1
by: davemcdonald | last post by:
ASP Javascript (Dreamweaver) insert and retreive Primary Key -------------------------------------------------------------------------------- Been pulling my hair out all week. I am working on...
0
by: troydixon | last post by:
Hello, I am new at this, and have been trying to insert data into a table by using the footer of a gridview (which I dont like) or by using a detials view on the same page that is doing the...
4
by: AXRabbit | last post by:
Hi, i am now doing a Car rental system web project. Well the interface is very similiar to http://www.avis.com.sg/, which i have extra modelname dropdownlist. Here is my code.Label 7 is just a...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.