PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > alt.comp.lang.php > Goto details page after insert record.
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Goto details page after insert record.

Réponse
 
LinkBack Outils de la discussion
Vieux 15/07/2007, 13h49   #1 (permalink)
bpsdg
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Goto details page after insert record.

Hi,

I'm using Dremweaver MX 2004.

I've just started into PHP / MySQL, but it works pretty well up until now.

One thing I can't seem to figure out at the moment.

I have a details (display only) page, which show one record. On that page I
have buttons for new-, update- and delete record. I got the update record
page working, so that after updating it will go to the same record on the
details page using an ID field.

I want the same behaviour from the insert record page. But the ID field is
an autoincrement field and I don't know how to get that when the new record
is created. In visual basic for example I can grab the new auto increment
field just before the record is created. But I can't find anything like that
in PHP. It can't always just be the highest number, because maybe two users
are adding records simultaneously.

Any suggestions?

Regards, Bas.




  Réponse avec citation
Vieux 15/07/2007, 14h03   #2 (permalink)
Ondøej Flídr - Sniper's softworks
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Goto details page after insert record.

bpsdg napsal(a):
> Hi,
>
> I'm using Dremweaver MX 2004.
>
> I've just started into PHP / MySQL, but it works pretty well up until now.
>
> One thing I can't seem to figure out at the moment.
>
> I have a details (display only) page, which show one record. On that page I
> have buttons for new-, update- and delete record. I got the update record
> page working, so that after updating it will go to the same record on the
> details page using an ID field.
>
> I want the same behaviour from the insert record page. But the ID field is
> an autoincrement field and I don't know how to get that when the new record
> is created. In visual basic for example I can grab the new auto increment
> field just before the record is created. But I can't find anything like that
> in PHP. It can't always just be the highest number, because maybe two users
> are adding records simultaneously.
>
> Any suggestions?
>
> Regards, Bas.
>
>
>
>

You can use SQL command "select * from yourTable order by id desc limit 1", which returns the newest
record in table. It should works if your application doesn't have so many request for inserting new
line at one time.When your application will generate more lines between inserting and selecting new
ID, you should use transaction in mysql and lock table for inserting.

Regards
OF

--
S pozdravem
Ondøej Flídr - Sniper's softworks
+420 776 167 963
ICQ: 248 888 883
Skype: snipers-softworks
flidr@snipers-softworks.net
http://www.snipers-softworks.net
  Réponse avec citation
Vieux 15/07/2007, 16h41   #3 (permalink)
Norman Peelman
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Goto details page after insert record.

bpsdg wrote:
> Hi,
>
> I'm using Dremweaver MX 2004.
>
> I've just started into PHP / MySQL, but it works pretty well up until now.
>
> One thing I can't seem to figure out at the moment.
>
> I have a details (display only) page, which show one record. On that page I
> have buttons for new-, update- and delete record. I got the update record
> page working, so that after updating it will go to the same record on the
> details page using an ID field.
>
> I want the same behaviour from the insert record page. But the ID field is
> an autoincrement field and I don't know how to get that when the new record
> is created. In visual basic for example I can grab the new auto increment
> field just before the record is created. But I can't find anything like that
> in PHP. It can't always just be the highest number, because maybe two users
> are adding records simultaneously.
>
> Any suggestions?
>
> Regards, Bas.
>
>
>
>


SELECT LAST_INSERT_ID() FROM table_name

Norm
  Réponse avec citation
Vieux 15/07/2007, 18h05   #4 (permalink)
Michael Fesser
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Goto details page after insert record.

..oO(Ondøej Flídr - Sniper's softworks)

>You can use SQL command "select * from yourTable order by id desc limit
>1", which returns the newest record in table.


You know what a race condition is?

Micha
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 11h26.


Édité par : vBulletin® version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,10118 seconds with 12 queries