•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 391,979 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,126 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 332 | Replies: 7
![]() |
•
•
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation:
Rep Power: 8
Solved Threads: 238
What do you mean by without using for or while loop ? What's the problem in inserting a record directly ? ie.,
insert into tablename (col1,col2) values ('val1','val2') Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
*PM asking for help will be ignored*
*PM asking for help will be ignored*
•
•
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation:
Rep Power: 8
Solved Threads: 238
If you know the values, you can do something like this.
This will insert 3 records to the table.
mysql Syntax (Toggle Plain Text)
INSERT INTO table (col1) VALUES (val1),(val2),(val3)
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
*PM asking for help will be ignored*
*PM asking for help will be ignored*
nave it is ok when we enter the records manually and we know the no. of records
Here it is not the case... I have an array having the value of several records that i it got as a result of a query..
I now want to insert these records into an another table without using the while or for loop...
Hope u get me..
Thanks in advance..
Jino.
Here it is not the case... I have an array having the value of several records that i it got as a result of a query..
I now want to insert these records into an another table without using the while or for loop...
Hope u get me..
Thanks in advance..
Jino.
We only have to do a very few things right in our life, so long as we don't do too many things wrong.
•
•
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation:
Rep Power: 8
Solved Threads: 238
If you use the mysqli interface, you can concat all queries into a single string, separated by semi-colons. Then all will be executed after one another. The error-handling will be more difficult though. See here:
http://nl.php.net/manual/en/mysqli.multi-query.php
http://nl.php.net/manual/en/mysqli.multi-query.php
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb PHP Marketplace
Similar Threads
- Shopping Cart Not Working (ASP.NET)
- display image from databse (MySQL)
- can we get the position of record while retriving records in sql server 2003 (MS SQL)
- WebBrowser do not show latest record (Visual Basic 4 / 5 / 6)
- INSERT INTO doing double duty (MySQL)
- Phonebook program! (C)
- Binary Search Tree (C++)
- radio button ASP question?? (ASP)
- Can Someone please check my project & comment/tips (C)
Other Threads in the PHP Forum
- Previous Thread: How do I know if the user monitor is off using javascript?
- Next Thread: Run PHP program



Linear Mode