| Index
» Projekty
» phpMyEdit
» Fórum
» Adding from copy button using auto increment |
 |
rimmo69
Založený: 08.07.2008
Príspevky: 9
Zaslal: 2008-08-08 18:40
Návrat hore
Odpovedať s citátom
|
I'd like to be able copy posts when adding new items and have the ID automatically filled out with the next highest ID number.
I managed to get the next highest ID when just clicking on the add button, by using
| Kód: |
mysql_connect("localhost", "*******", "*******") or die(mysql_error());
mysql_select_db("rimmo_dk") or die(mysql_error());
$data = mysql_query("SELECT MAX(Inventar) AS id FROM medico");
$row = mysql_fetch_array($data);
$newinventar=$row[id]+1; |
Then the default value is set to $newinventar....
But is there any way to override one field when copying.... This would be a great help for me and my colleges.
Fingers crossed.
|
michal
Založený: 17.06.2003
Príspevky: 537
Bydlisko: Slovakia
Zaslal: 2008-09-08 12:59
Návrat hore
Odpovedať s citátom
|
alter $newvals in before trigger.
database connection is not needed in trigger, you should use $this->dbh as database connection handler.
|
rimmo69
Založený: 08.07.2008
Príspevky: 9
Zaslal: 2008-09-08 18:06
Návrat hore
Odpovedať s citátom
|
Thanks for the response... I am still trying to figure this out.... I'm gonna experiment with what you have given me.
I'll need to read up on triggers first though.
Cheers Graham
|
|
Odoslať novú tému
Odpovedať na tému
|
|
|
|