Trouble in last id

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • smcp
    New Member
    • Jul 2007
    • 1

    Trouble in last id

    hi all..

    i am newbie in php-mysql. i have doubt to access the max id using php.
    here is the problem.

    member table
    ---------------
    id auto_increment
    name varchar(50);
    -------
    accessing data through html form, then dumping to mysql working nicely.but when accesing LAST DATA from mysql through browser using php code shows nothing.

    [code=php]
    <?php

    mysql_connect(" localhost","roo t","") or die (mysql_error()) ;
    $dblink = mysql_select_db ("test") or die (mysql_error()) ;
    $res = mysql_query("se lect max(id) from members",$dblin k);
    $maxid = mysql_result($r es,0,"MAX(id)") ;
    $result=mysql_q uery("select * from members where id=$maxid");

    $row = mysql_fetch_arr ay($result, MYSQL_ASSOC);
    echo "ID : {$row['id']} , ". "Name : {$row['name']} <br>";
    mysql_close($db link);

    ?>
    [/code]

    please help me

    thanks in advance
    Last edited by Atli; Jul 19 '07, 04:16 PM. Reason: Added code tags
  • debasisdas
    Recognized Expert Expert
    • Dec 2006
    • 8119

    #2
    Hi
    smcp
    Welcome to TSDN.

    You have reached the right place for knowledge shairing.

    Here you will find a vast resource of related topics and code.

    Feel free to post more doubts/questions in the forum.

    But before that give a try from your side and if possible try to post what/how you have approached to solve the problem.

    It will help Experts in the forum in solving/underestanding your problem in a better way.

    Please follow the posting guidelines in every new post/reply.

    Regards

    Debasis

    Comment

    Working...