hey guys,
I just wanna know could i insert data into a table in sql according to specific id?
like this -> mysql_query (" INSERT INTO pix (title,imgdata) VALUES (" " , " " ) WHERE id = '$id' ")
my question is,Could i use the word WHERE after the values? If not, is there any other code that could store data within my specific column?
I wanted to do this :
1) Page 1 - admin key in name and id and submit
2) Page 2 - admin could stored data automatically stored into sql table according to ID that been key in earlier.
How do i read the key in ID in the previous page???? Cookies izzit?
pix table : | id | title | imgdata |
Please HELP me by give me a hint!
Thanks
Azhan
_________________________
http://www.productcoverdesign.com- "Cheapest E-cover Design"
need INSERT INTO code
Moderator: General Moderators
Re: need INSERT INTO code
You can not use the 'WHERE' clause in an insert query as it has no meaning (you are inserting into a table)
The MySQL manual on INSERT syntax - http://dev.mysql.com/doc/refman/5.0/en/insert.html
The MySQL manual on INSERT syntax - http://dev.mysql.com/doc/refman/5.0/en/insert.html
-
youdontmeanmuch
- Forum Newbie
- Posts: 2
- Joined: Sun Jul 06, 2008 6:47 am
Re: need INSERT INTO code
If you could explain your situation a little more than I might be able to help you. From what I understand you are using the wrong command. Have a create a field in the table for the key, have the default be able to be NULL or something like that and then when the admin enters the key you UPDATE the table to the key they specified and then SELECT the key on the next page? Although I do think it might be better to have a cookie or SESSION, again... could help you more if you explain your situation.
Re: need INSERT INTO code
sure thing..and thanks for your concern anyway...
here's what im trying to do.
i have two tables that is patientlist and pix
patientlist table : |id|name|docassign
pix table : |id|title|imgdata
for the first page - Admin will key in only patient's ID and the page will detect whether the ID is in the database or not.
for the second page - After log in with the patient's ID, the admin will upload an image together with the title. And after done browsing image and named the title, the admin will submit the data. The data will be automatically INSERT into PIX table according to ID that had been login before.
My problem here now is to edit the coding of image uploading script so that it will be insert according to the login ID since the code seems quite complex to me.
below are the portion of UPLOADING script that i get..
$_REQUEST[whatsit] is the title that had been inserted in the form
$image is the address of the browsed image
the form are look like this

Again : MY problem here is how to insert the image and the title into the pix table according to patient's ID that had been log in before.
thanks,
hope that u guys got a solution for this matter
Azhan
_________________________
http://www.productcoverdesign.com- " Cheapest E-cover Design"
here's what im trying to do.
i have two tables that is patientlist and pix
patientlist table : |id|name|docassign
pix table : |id|title|imgdata
for the first page - Admin will key in only patient's ID and the page will detect whether the ID is in the database or not.
for the second page - After log in with the patient's ID, the admin will upload an image together with the title. And after done browsing image and named the title, the admin will submit the data. The data will be automatically INSERT into PIX table according to ID that had been login before.
My problem here now is to edit the coding of image uploading script so that it will be insert according to the login ID since the code seems quite complex to me.
below are the portion of UPLOADING script that i get..
Code: Select all
// Insert any new image into database
if ($_REQUEST[completed] == 1) {
move_uploaded_file($_FILES['imagefile']['tmp_name'],"latest.img");
$instr = fopen("latest.img","rb");
$image = addslashes(fread($instr,filesize("latest.img")));
if (strlen($instr) < 149000) {
mysql_query ("INSERT INTO pix (title, imgdata) values
(\"".$_REQUEST[whatsit]."\", \"".$image."\")");
} else {
$errmsg = "Too large!";
}$image is the address of the browsed image
the form are look like this

Again : MY problem here is how to insert the image and the title into the pix table according to patient's ID that had been log in before.
thanks,
hope that u guys got a solution for this matter
Azhan
_________________________
http://www.productcoverdesign.com- " Cheapest E-cover Design"