Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How can check info of last record in recordset.

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
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…
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.
Suggested Courses

916 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