PHP mysql_data_seek() Function Example

PHP mysql_data_seek() Function Example


Posted in : PHP Posted on : February 5, 2011 at 5:40 PM Comments : [ 0 ]

The mysql_data_seek() function is used to move internal result pointer. It return true on success or false on failure.

PHP mysql_data_seek() Function Example:

The mysql_data_seek() function is used to move internal result pointer. It return true on success or false on failure.

Example:

<?php
$connection = mysql_connect("localhost", "root", "root");
if (!$connection)
{
die('Could not connect: ' . mysql_error());
}
else{

$db_selected = mysql_select_db("php_mysql",$connection);

$sql = "SELECT * from user";
$result = mysql_query($sql,$connection);
print_r(mysql_fetch_row($result));
echo "<br />";
mysql_data_seek($result,0);
print_r(mysql_fetch_row($result));
}
mysql_close($connection);
?> 

In this example we have used mysql_data_seek() function that move the result pointer on 0 in the result set.

The database 'user' table records is:

Output:

Array ( [0] => 3 [1] => Deepak [2] => deepak@rediffmail.com [3] => Noida ) 
Array ( [0] => 3 [1] => Deepak [2] => deepak@rediffmail.com [3] => Noida ) 

Download Example Code

Go to Topic «PreviousHomeNext»

Your Comment:


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 

 
Tutorial Topics