Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query for Inserting multiple empty rows 3

Status
Not open for further replies.
are there any fields which woul be popultated at the ned of the query (id in an auto_increment for example?) ***************************************
Party on, dudes!
[cannon]
 
Well it would be sad to try and enter several blank lines and have no proof that it actually worked, also if its an ID you have a base to start adding from.

In all honesty I think a php while() loop is going to be the easiest(read quickest as well), but I'll happily wait for someone to prove me wrong ;) ***************************************
Party on, dudes!
[cannon]
 
well, try this sql statement

INSERT INTO <table_name> (<autoincrement_column_name>) VALUES (''), (''), ('')

this should insert three empty rows
 
I think Homer once said....
Doh!
(_8(0)

Nice one Piti, star for j00 :) ***************************************
Party on, dudes!
[cannon]
 
Well, the query given by Piti will also force me to use a PHP loop in the case I want to give the user the choice of how many rows he wants to insert before applying the query.

I thought there was a simple query with a numeric value for the number of rows to be added. Thus, a single PHP variable in the query could have done the trick, you see.

Anyway, thanks for the help. My Work...
...and More...
 
Sledia so try this
u will need a table with enough rows - it doesn't matter what kind of table, it just needs enough rows

INSERT INTO <target_table_name> (<column in target table>) SELECT NULL FROM <&quot;source&quot;_table_name> LIMIT N

where N is the number of rows u want to enter
 
Hello again Piti,

I already thought about this way but the problem is that it brings more hassle than using a PHP loop.
I'm lazy you know.. :)

Also, in order to create the table that has plenty of rows in the first place, I will have to write a PHP loop!

Anyway, here is a star for the effort.


My Work...
...and More...
 
well, just limit the number of possible inserted rows to the max in one of your table, or create one table just for this purpose, u will not be forced to create it everytime user wants to insert rows

btw i don't understand the purpose of this insert - why should a user want to insert empty rows in a table -allocating space? ;-)
 
I'm creating a browser based interface whose purpose is to look like an Excel interface a little bit and to allow people to edit every table/database on their remote/local mysql server very quickly.
I don't like phpmyadmin.

It's finished, but I wanted to shorten the code as much as possible.
I'm planning to design a Flash version of it for a nicer interface once I know how to do.

My Work...
...and More...
 
And to stop you from using a while loop .... :)

$x_rows=30; // however many you want here
$new_rows=substr(str_repeat(&quot;(''),&quot;, $x_rows),0,-1); // repeat the (''), as many times as required and strip the trailing ,

$sql=&quot;INSERT INTO table_name (autoincrement_column_name) VALUES $new_rows&quot;; ***************************************
Party on, dudes!
[cannon]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top