| | |
PHP/MySql - Inserting Multiple Records
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
I want to insert records into multiple tables at one go, I am doing this in the following way, is this the correct way of doing? If not, what is the better way?
Please help
Thanx
PHP Syntax (Toggle Plain Text)
mysql_query("insert into table1 values('abc')"); mysql_query("insert into table2 values('ttt')"); mysql_query("insert into table3 values('5t6')"); mysql_query("insert into table4 values('ghy')"); mysql_query("insert into table5 values('gfd')");
Please help
Thanx
Yep. This is correct. But, its a good practice to have column name in your insert query. And also, Dont execute your query directly. Store the query in a variable and then execute it. This way, if you encounter any problem, you can easily print the query for manual testing.
ie.,
Cheers,
Naveen
ie.,
php Syntax (Toggle Plain Text)
$query = "insert into table1 (col1) values ('ttt')"; mysql_query($query);
Naveen
Ignorance is definitely not bliss!
*PM asking for help will be ignored*
*PM asking for help will be ignored*
![]() |
Other Threads in the PHP Forum
- Previous Thread: Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource
- Next Thread: PHP/MySQL Add overall price from output
| Thread Tools | Search this Thread |
Tag cloud for PHP
.htaccess access ajax apache api array beginner binary broken cakephp checkbox class cms code cron curl database date development directory display download dynamic echo email error file files filter folder form forms function functions gc_maxlifetime google host href htaccess html image include insert integration ip java javascript joomla limit link login loop mail memmory memory menu mlm mod_rewrite multiple mysql navigation oop parse parsing paypal pdf php problem query radio random recursion regex remote script search server sessions sms snippet soap source space sql structure syntax system table thesishelp tutorial update upload url validation validator variable video web xml youtube






