Exforsys
+ Reply to Thread
Results 1 to 5 of 5

Problem in fetching rows from mysql in php?

This is a discussion on Problem in fetching rows from mysql in php? within the PHP forums, part of the Programming Talk category; Hi Friends, I tried: I inserted a row in mysql using php in the first webpage and second webpage i ...

  1. #1
    JackyRock is offline Junior Member Array
    Join Date
    Feb 2010
    Answers
    1

    Problem in fetching rows from mysql in php?

    Hi Friends,
    I tried:
    I inserted a row in mysql using php in the first webpage and second webpage i tried to retrieve it.
    I got:
    But in the next page i did not get the lastely inserted row.
    When inserted the another row, i was able to get the first inserted row and not the lastest row.

    So every time i miss the last inserted row the first time and when then i was able to get it as soon as i insert another row.

    How to solve this issue? Is it something related to commit i am missing here?




    Last edited by admin; 02-11-2010 at 12:12 PM.

  2. #2
    simran10101 is offline Junior Member Array
    Join Date
    Mar 2011
    Answers
    3
    To resolve this pbm I need code.


  3. #3
    lokeshm is offline Member Array
    Join Date
    Apr 2005
    Answers
    64
    I suggest you make use of mysql_insert_id() function.

    Whenever you insert a record, you can get the value stored in the AUTO_INCREMENT column of the last inserted record by calling the mysql_insert_id() function.


  4. #4
    svishnu is offline Junior Member Array
    Join Date
    Apr 2011
    Answers
    2
    just try

    Code:
    <?php
    //obtain connection
     $query = "SELECT * FROM Table";
    $result = mysql_query($query);
    if(!$result){
    
    }
    ?>


    Last edited by admin; 04-19-2011 at 08:07 PM.

  5. #5
    svishnu is offline Junior Member Array
    Join Date
    Apr 2011
    Answers
    2
    Code:
    <?php
    //obtain connection
    $query = "SELECT * FROM Table";
    $result = mysql_query($query);
    if(!$result){
        die mysql_error();
    }
    else{
        while($row = mysql_fetch_assoc($result)){
             echo $row['rowname in table'];
            
        }
    }
    //close connection
    ?>
    so you will get all rows

    Last edited by admin; 04-19-2011 at 08:06 PM.

    •    Sponsored Ads



Latest Article

Network Security Risk Assessment and Measurement

Read More...