Jump to content

Problem in fetching rows from mysql in php?

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
4 replies to this topic

#1
shikha985

shikha985

    Newbie

  • Members
  • Pip
  • 2 posts
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?

Edited by Orjan, 09 March 2010 - 01:25 AM.
Removed spam


#2
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
What is your table structure? Do you have an indicator of when something was added?
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#3
joyo

joyo

    Newbie

  • Members
  • PipPip
  • 17 posts
I also don't know this problem , I want to know the reason too.

#4
abdul.gafur

abdul.gafur

    Learning Programmer

  • Members
  • PipPipPip
  • 42 posts
if you use a primary key that auto increment, you can get the last row with
"select * from yourtable order by yourid desc"

#5
joyo

joyo

    Newbie

  • Members
  • PipPip
  • 17 posts

abdul.gafur said:

if you use a primary key that auto increment, you can get the last row with
"select * from yourtable order by yourid desc"

good, also you can append " LIMIT 1" to the sql script , it would imporve the Execution efficiency.