使うmysql_insert_id()
のは方法です。しかし、データベースにクエリを実行したくないが、まだそれを持っている場合は、この方法で実行できます。以下に例を示します
<form name="frm" method="POST" action="display.php">
<input type="text" name="your_name" value="" />
<input type="text" name="age" value="" />
<input type="submit" name="save" value="Save" />
</form>
これで、display.phpページに
<?php
// DO YOUR DATABASE CONNECTIVITY
$name = $_POST['your_name'];
$age = $_POST['age'];
$query = "insert into table_name values('$name','$age')";
if(mysql_query($insert)) {
?>
<table>
<tr>
<td>Name</td>
<td>Age</td>
</tr>
<tr>
<td><?php echo $name;?></td>
<td><?php echo $age;?></td>
</tr>
</table>
<?php } else { echo "No Insertion"; } ?>
mysql_* 関数は減価償却されていることに注意してください。だからそれらを避けてください。SQLインジェクションもチェック