PDA

View Full Version : Inserting Data from html form into 3 tables



bloom23
September 8th, 2008, 12:54 AM
Hey guys, I'm creating a basic CMS that will let me update items in my portfolio. Now, what I want to do is tag each record as web, interactive, or graphic so I can later display the record sets in different places.

Now I know the code to insert one record, but not 3. Here is what I have for one of them:


if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "folioUpdate")) {
$insertSQL = sprintf("INSERT INTO folio (project_title, project_descrip, project_img, featured) VALUES (%s, %s, %s, %s)",
GetSQLValueString($_POST['title'], "text"),
GetSQLValueString($_POST['descript'], "text"),
GetSQLValueString($_POST['image'], "text"),
GetSQLValueString(isset($_POST['featured']) ? "true" : "", "defined","'Y'","'N'"));

mysql_select_db($database_databaseName, $databaseName);
$Result1 = mysql_query($insertSQL, $databaseName) or die(mysql_error());Now I've been reading about this code here, will it work?

$Result1 = mysqli_multi_query($insertSQL, $databaseName) or die(mysql_error());So what I can't figure out (or find) is the sql and php code... My other tables look something like this:

tags
tag_id
tag_name

foliotags
proj_id
tag_id

If anyone could help me out here, I'd be forever in debt :P

bloom23
September 9th, 2008, 04:12 PM
Well I've figured it out..

I was going about the whole thing backwards I believe, but here is the link to useful information I found in the PHP documentation regarding inserting info into multiple tables:

http://us3.php.net/mysql_insert_id