msafvati Posted September 7, 2008 Share Posted September 7, 2008 Hi my friends How can I move between Records in Database such as move to next record or last record similar to (movenext). I use from Odbc function Please help me Link to comment https://forums.phpfreaks.com/topic/123100-moving-between-records-in-db/ Share on other sites More sharing options...
steveclondon Posted September 7, 2008 Share Posted September 7, 2008 Use a loop eg while (myInfo=mysql_fetch_array($result) { echo $myInfo['NameOfYourFieldHere']; } Link to comment https://forums.phpfreaks.com/topic/123100-moving-between-records-in-db/#findComment-635738 Share on other sites More sharing options...
msafvati Posted September 7, 2008 Author Share Posted September 7, 2008 thank u my friend but i want to know that loop is correct for ODBC? Link to comment https://forums.phpfreaks.com/topic/123100-moving-between-records-in-db/#findComment-635742 Share on other sites More sharing options...
Adam Posted September 7, 2008 Share Posted September 7, 2008 Think it works pretty much the same, not 100% but... while ($row = odbc_fetch_array($query)) { print 'Field 1: ' .$row[0]. ' Field 2: ' .$row[1]. '<br />'; } Link to comment https://forums.phpfreaks.com/topic/123100-moving-between-records-in-db/#findComment-635745 Share on other sites More sharing options...
msafvati Posted September 8, 2008 Author Share Posted September 8, 2008 Hi my friend please Look this Script: i write it for Moving between Record.I want when Click on Next button, it show me only CONTENT of the First Record and the next Show me Second Record and 3 and ... but when i Click on Next botton it show me all of Records in DB. Please tell me do thease Script are Correct? Please Help me thank u <form action="http://127.0.0.1:8080/odbc_fetch_row.php" method="POST"> <input type="submit" value="next" name="next"><br><br> <?php $connection= odbc_connect("test", "", ""); $query = "SELECT username FROM tbltest"; $Res = odbc_do($connection, $query); if (isset($_POST['next'])){ $i=0; while (odbc_fetch_row($Res)){ $i = odbc_result($Res,'username'); echo "$i </br>"; } } $i++; odbc_close($connection); ?> and <form action="http://127.0.0.1:8080/TT.php" method="POST"> <input type="submit" value="next" name="next"><br><br> <?php $connection= odbc_connect("test", "", ""); $query = "SELECT username FROM tbltest"; $Res = odbc_do($connection, $query); if (isset($_POST['next'])){ $i=0; while(odbc_fetch_row($Res)){ $r=odbc_result($Res,$i); echo $r; } $i++; } odbc_close($connection); Link to comment https://forums.phpfreaks.com/topic/123100-moving-between-records-in-db/#findComment-636417 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.