Ciao ragazzi,
Vi volevo chiedere se con la funzione:
mysql_insert_id()
oltre ovviamente all'id, è possibile passare anche i dati ad esso legati. Vi posto un pezzo di codice così forse riesco a spiegarmi meglio:
<?php
include("config.inc.php");
include("connect.php");
if (isset($_GET['tel'])) {$tel=$_GET['tel'];} else {$tel="";}
if (isset($_GET['ind'])) {$ind=$_GET['ind'];} else {$ind="";}
if (isset($_GET['nome'])) {$nome=$_GET['nome'];} else {$nome="";}
$ip=$_SERVER['REMOTE_ADDR'];
?>
<form action = "<?php echo $_SERVER['PHP_SELF']; ?>" method = "post">
<input name="tel" type="text" id="tel" size="20">
</h5>
<h5> <span class="Stile6">Indirizzo</span>
<input name="ind" type="text" id="ind" size="30">
</h5>
<h5><span class="Stile6">Nome </span> </span>
<input name="nome" type="text" id="nome" size="20">
</h5>
<div align="center">
<input type="submit" class="button" name="Submit2" id="Submit" value="Inserisci ">
<?php
$tel=$_POST['tel'];
$ind=$_POST['ind'];
$nome=$_POST['nome'];
$query="INSERT INTO clienti ( tel, ind, nome)
VALUES
( '$tel','$ind','$nome')";
mysql_query($query,$db);
printf("Last inserted record has id %d\n", mysql_insert_id());
?>
Questo mi restituisce: Last inserted record has id 14
Ma per estrarre anche gli altri dati di quel record, tel, ind, nome, c'è un modo?
Grazie tante![]()