Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How can check info of last record in recordset.

Posted on 2011-09-24
3
Medium Priority
?
248 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 2000 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
This article discusses how to implement server side field validation and display customized error messages to the client.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

722 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