Reseting the mysql pointer


Sometimes you need access the mysql result set after you have already accessed it using




or whatever. The chances are if you try a mysql_fetch_anything()*[not a really method guys] the function will return a false cause it has reached the end of the result set.

So how do you fix that? Easy. php has a function called

mysql_data_seek(resource $result, int $row_number)

, where $result is your result set, eg

$result = mysql_query('Select * from table');

and $row_number is the row you would like to move the pointer to. This number ranges from 0 to

msyql_num_rows() - 1

So if you want to go to the begining you would use

mysql_data_seek($result, 0);

Hope this helps

About the author

Talifhani Luvhengo

A collection of particles named Tali Luvhengo

1 comment

  • Wow! What a blog. You have a real knack for making a blog readable and easy on the eyes. I find CMS applications a very interesting area. I don’t have time to read all the articles right now, I found your site while I was looking for something else on but I have bookmarked the homepage and will return soon to read your latest updates. I have worked with CMS programs for eight years now. Which CMS do you find to be the most scalable? I’ve worked with several different applications and they each have their pluses and minuses. So many choices…Visit my site if you’d like to read more. Thanks again for a great site.


Page optimized by WP Minify WordPress Plugin