Reply to Re: acquiring value of primary key from uploaded file

Your name:

Reply:


Posted by frizzle on 07/17/06 21:47

Chris wrote:
> I have a PHP file upload feature that also gives the user the option to
> assign more than 1 project association to the file. The file's name, title,
> primary project, etc. is inserted into a document link table in a MySQL db
> after the file is uploaded. The secondary (and multiple) project(s) are also
> selected using a separate list box (there are 2 boxes - one for the primary
> project, and one for any/all associated projects) The selected values from
> the secondary box need to be inserted into a junction table that reflects
> both the id for the newly uploaded file and the secondary project(s) - with
> a primary key for the association itself, i.e,:
>
> assoc_id doc_id proj_id
> 1 265 5
> 2 265 3
> 3 265 1
>
> I would use a foreach statement to pull the projects from the select list,
> but how do I get the newly generated doc_id in order to pass that value to
> the association table? Can I assign it a variable at the same time I insert
> the data into the primary table? The ID is auto-incremented and is inserted
> into the primary table as follows:
>
> $tool_insert = "INSERT INTO tools VALUES ('', '$uploadedname', '$tooltitle',
> '$tooldesc', '$tooltype_id', '$toolcat_id', '$primeproj_id', '$location')";
>
> Thanks for any help.
>
> Christina

I believe you're looking for mysql_last_insert_id()

Frizzle.

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация