Jump to content
alpha02

SQL: get row num

Recommended Posts

Hello!I want to make a function to return the row number. Example:table: orders|_____ID_____|_________NAME__________||_____4______|______NOBODY__________||_____3______|_______NONE____________||_____5______|_______NONAME__________||_____2______|_______NOBODY__________|something like:$resource = mysql_query ("SELECT * FROM orders WHERE id = '5'");$rownum = getrownum ($resource);echo $rownum; //write 2I need this for my forum, please help! :)

Share this post


Link to post
Share on other sites
Hello!I want to make a function to return the row number. Example:table: orders|_____ID_____|_________NAME__________||_____4______|______NOBODY__________||_____3______|_______NONE____________||_____5______|_______NONAME__________||_____2______|_______NOBODY__________|something like:$resource = mysql_query ("SELECT * FROM orders WHERE id = '5'");$rownum = getrownum ($resource);echo $rownum; //write 2I need this for my forum, please help! :)

$rownum = 0;$i = 0;$resource = mysql_query ("SELECT * FROM orders");$numberOfRecords = mysql_numrows($resource);while($i < $numberOfRecords){     if(mysql_result($resource,$i,'id') == '5');          $rownum = $i;     $i++;}

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×