PDA

View Full Version : posting records to table


rayzun
05-19-2005, 12:23 AM
Im building a PHP page where Im allowing visitors to input information using a online form.

With MySql

The table is got the first field primary (id)
1-8000 records

there are another 22 empty fields in this table.
year, color etc...

each (id) field is unique to a product model

Im asking how is it possible to post
multiple entries to the unique (id) field?

I would then be able to query the table and display entry after entry for the unique id field

Tangerine Dream
05-22-2005, 12:33 AM
Im asking how is it possible to post
multiple entries to the unique (id) field?
Hi, if you mean the same value multiple times, it's impossible due to UNIQUE or PK constraint you have. You may want to use IGNORE keyword for INSERT statement:


If you specify the IGNORE keyword in an INSERT statement, errors that occur while executing the statement are treated as warnings instead. For example, without IGNORE, a row that duplicates an existing UNIQUE index or PRIMARY KEY value in the table causes a duplicate-key error and the statement is aborted. With IGNORE, the error is ignored and the row is not inserted. Data conversions that would trigger errors abort the statement if IGNORE is not specified. With IGNORE, invalid values are adjusted to the closest value values and inserted; warnings are produced but the statement does not abort. You can determine with the mysql_info() C API function how many rows were inserted into the table.

If you mean to insert non-atomic values, it's possible using string concatenation, but you should reconsider your database design because your table is not normalized