Go Back   Access World Forums > Apps and Windows > Web Design and Development > PHP & MySQL

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 04-07-2015, 06:13 AM   #1
Steve R.
Retired
 
Steve R.'s Avatar
 
Join Date: Jul 2006
Location: Morehead City, North Carolina
Posts: 1,734
Thanks: 95
Thanked 104 Times in 92 Posts
Steve R. will become famous soon enough Steve R. will become famous soon enough
Get Current Row Number (Cursor Location)

mysqli_data_seek works to get to a specific record. The problem that I am having is finding a method that returns the current cursor location.

I am developing PHP code to allow scrolling to either the next record or to the prior record. One way to accomplish this would be to have a query which keys the row number to the primary key (IssueIDNUM).

Would that be the way to go, or are there other alternative approaches?

Code:
$query = "Select (@row_number:=@row_number + 1) AS rownumber, IssueIDNUM FROM tblIssueList, (SELECT @row_number:=0 ) AS tblTemp ORDER by IssueDate DESC, IssueIDNUM";

__________________
Now using Linux (Ubuntu).
Doing database development with Firefox/MariaDB.
Steve R. is offline   Reply With Quote
Old 04-08-2015, 05:48 PM   #2
Steve R.
Retired
 
Steve R.'s Avatar
 
Join Date: Jul 2006
Location: Morehead City, North Carolina
Posts: 1,734
Thanks: 95
Thanked 104 Times in 92 Posts
Steve R. will become famous soon enough Steve R. will become famous soon enough
Re: Get Current Row Number (Cursor Location)

Since posting, I have been experimenting with how to get the current row number. The SQL query in the original post is unnecessary. The "better" query is below.

Code:
$query = "Select IssueIDNUM FROM tblIssueList ORDER by IssueDate DESC, IssueIDNUM ";
A "beta" version of how to get the current row (cursor position) is below. I think the code can be substantially shrunk as I learn more.

Code:
$current_row_number = return_row_number();
Code:
<?php

      function return_row_number() 
	{ 	
		// Loop through the Array; Get Row Number for the current issue
		global $result,$issuenum, $rowcount;
		$count =0;
		mysqli_data_seek($result, 0);
		while($row=mysqli_fetch_array($result, MYSQL_ASSOC))
   		{
      		++$count;
      		if($issuenum == $row['IssueIDNUM'])
      		{
					return $count -1;
					break;
      		}
         }	
	} 
?>
I also found on the W3 School website a listing of PHP 5 Array Functions. Yea, now I can get some DAO compatibility.
__________________
Now using Linux (Ubuntu).
Doing database development with Firefox/MariaDB.
Steve R. is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Question How to suppress the location of the cursor in the standard toolbar Guus2005 General 1 02-09-2011 03:04 AM
Leave cursor on current form field Cameo Forms 8 02-08-2010 10:05 AM
Cursor location in a text box jet46 Forms 1 06-17-2005 11:28 AM
Form Cursor location dynamictiger Forms 1 09-21-2002 05:49 AM
Cursor Location KAC Forms 5 01-30-2002 05:40 AM




All times are GMT -8. The time now is 01:05 PM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World