Solved

How can check info of last record in recordset.

Posted on 2011-09-24
3
241 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
  • 2
3 Comments
 
LVL 3

Expert Comment

by:dkellner
Comment Utility
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
Comment Utility
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
Comment Utility
Works perfect thanks.  I had read the manual but just could not figure our. Thanks
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
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.

763 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now