
- Forum
- Programming Talk
- PHP
- Problem in fetching rows from mysql in php?
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 ...
-
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 11:12 AM.
-
03-10-2011, 03:09 AM #2
- Join Date
- Mar 2011
- Answers
- 3
To resolve this pbm I need code.
-
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.
-
just try
Code:<?php //obtain connection $query = "SELECT * FROM Table"; $result = mysql_query($query); if(!$result){ } ?>
Last edited by admin; 04-19-2011 at 07:07 PM.
-
so you will get all rowsCode:
<?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 ?>
Last edited by admin; 04-19-2011 at 07:06 PM.
-
Sponsored Ads

Reply With Quote





