Solved

How can check info of last record in recordset.

Posted on 2011-09-24
3
246 Views
Last Modified: 2012-06-27
Hello how do i check some of the information of the last record in my recordset.  
I want to do an if statement that if specified field in the Last record in the recordset equals O.  I know that may not make much since but I use this recordset in a do while but I also need to know some info about the last record.


mysql_select_db($database_carrollton, $carrollton);
$query_event_comment = "SELECT * FROM comments, members WHERE com_evn_id = $event_comment_id AND com_mem_id = mem_member_id AND com_status = 0 ORDER BY com_entry_date ASC  ";
$event_comment = mysql_query($query_event_comment, $carrollton) or die(mysql_error());
$row_event_comment = mysql_fetch_assoc($event_comment);
$totalRows_event_comment = mysql_num_rows($event_comment);

Open in new window

0
Comment
Question by:Luey
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 3

Expert Comment

by:dkellner
ID: 36593062
With mysql_data_seek() you can seek to the Nth record.
mysql_num_rows() will tell you how many there.

http://php.net/manual/en/function.mysql-data-seek.php
http://php.net/manual/en/function.mysql-num-rows.php
0
 
LVL 3

Accepted Solution

by:
dkellner earned 500 total points
ID: 36593077
So in your case it will be like

mysql_data_seek($event_comment, $totalRows_event_comment - 1);
$lastRecord_event_comment = mysql_fetch_assoc($event_comment);
0
 

Author Closing Comment

by:Luey
ID: 36593118
Works perfect thanks.  I had read the manual but just could not figure our. Thanks
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

These days socially coordinated efforts have turned into a critical requirement for enterprises.
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question