| | |
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 directory display download dynamic echo email encode error fcc file files folder form forms function functions google howtowriteathesis href htaccess html image images include insert integration ip java javascript joomla ldap limit link login loop mail menu mlm mod_rewrite multiple multipletables mysql oop open parse paypal pdf php problem provider query radio random recursion regex remote script search server sessions sms soap source space sql strip_tags structure syntax system table template tutorial update upload url validation validator variable video web xml youtube






