Mutley Posted October 8, 2006 Share Posted October 8, 2006 I've done a form but I want certain areas (fields) to insert into different tables.Do I do this:[code=php:0] $sql = "INSERT INTO `pages` "; $sql .= "(this, that) "; $sql .= "VALUES "; $sql .= "('".$this."', '".$that."')";[/code]...and repeat it above each field I want it to go into a different table or can I do something like this:[code=php:0] $sql = "INSERT INTO `table1` AND `table2` AND `table3` "; $sql .= "(*) "; $sql .= "VALUES "; $sql .= "('".$this."', '".$that."')";[/code]Thanks in advance. Quote Link to comment Share on other sites More sharing options...
Neptunus Maris Posted October 8, 2006 Share Posted October 8, 2006 [sup]<?php//do some variable work$this = $_POST['this'];$that = $_POST['that'];$query = "INSERT INTO $table VALUES(' ', '$this')";$result = mysql_query($query, $connect) or die(mysql_error());//create a second query clause$query = "INSERT INTO $table2 VALUES(' ' , '$that')";$result = mysql_query($query, $connect) or die(mysql_error());?>[/sup] Quote Link to comment Share on other sites More sharing options...
Neptunus Maris Posted October 8, 2006 Share Posted October 8, 2006 No...like this ..sorry:INSERT INTO table1, table2, table3, VALUES(' ' , '$this', '$that')"; dont do table1 AND table table2Neptune Quote Link to comment Share on other sites More sharing options...
Barand Posted October 8, 2006 Share Posted October 8, 2006 Well you must have a different manual from me because I can't find an INSERT syntax that allows multiple tableshttp://dev.mysql.com/doc/refman/5.0/en/insert.html Quote Link to comment Share on other sites More sharing options...
Mutley Posted October 9, 2006 Author Share Posted October 9, 2006 [quote author=Barand link=topic=110906.msg449021#msg449021 date=1160347884]Well you must have a different manual from me because I can't find an INSERT syntax that allows multiple tableshttp://dev.mysql.com/doc/refman/5.0/en/insert.html[/quote]Would you like to explain how it can be done? Quote Link to comment Share on other sites More sharing options...
Mutley Posted October 9, 2006 Author Share Posted October 9, 2006 Anyone? :( Quote Link to comment Share on other sites More sharing options...
Barand Posted October 9, 2006 Share Posted October 9, 2006 You posted 2 options. The manual, at least my copy, indicates it cannot be the second. Quote Link to comment Share on other sites More sharing options...
Mutley Posted October 9, 2006 Author Share Posted October 9, 2006 Ah, ok, I was hoping for a shorter way without repeating it, thanks though. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.