Jump to content


Photo

view previous entry


  • Please log in to reply
5 replies to this topic

#1 takeiteasy

takeiteasy
  • Members
  • PipPipPip
  • Advanced Member
  • 32 posts

Posted 11 July 2006 - 10:09 AM

Hi there,
Just want to ask if there's any PHP code that can display the data which has just been stored in the database?
thanks

#2 ToonMariner

ToonMariner
  • Members
  • PipPipPip
  • Advanced Member
  • 3,342 posts
  • LocationNewcastle upon Tyne, UK

Posted 11 July 2006 - 10:16 AM

mysql_insert_id();
follow me on twitter @PHPsycho

#3 takeiteasy

takeiteasy
  • Members
  • PipPipPip
  • Advanced Member
  • 32 posts

Posted 11 July 2006 - 10:24 AM

can u further explain on how this code works?thanks

#4 brown2005

brown2005
  • Members
  • PipPipPip
  • Advanced Member
  • 943 posts

Posted 11 July 2006 - 10:27 AM

yeah use mysql_insert_id(); to select the record last inserted and then call it using this

$inserted_id = mysql_insert_id();
     
$sql = "SELECT * FROM table WHERE id='$inserted_id ' LIMIT 1";
$query = mysql_query($sql ) or die(mysql_error());

while($array= mysql_fetch_array($query))
{
$array['fieldnames'];
}


#5 takeiteasy

takeiteasy
  • Members
  • PipPipPip
  • Advanced Member
  • 32 posts

Posted 11 July 2006 - 10:55 AM

oh. i get it. thanks alot!  ;)

#6 brown2005

brown2005
  • Members
  • PipPipPip
  • Advanced Member
  • 943 posts

Posted 11 July 2006 - 10:56 AM

no problem, let me know if it works, :)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users