Solved

How can check info of last record in recordset.

Posted on 2011-09-24
3
245 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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
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…
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…

749 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