PHP Tutorial





Español Français 中文 Deutsch Portuguese Japanese nederlands
   
 
PHP Topics
Introduction Introduction
Syntax Syntax
Data Types Data Types
Operators Operators
Control Structures Control Structures
Functions Functions
Pre-defined Function Pre-defined Function
Calendar Functions Calendar Functions
Date and Time Date and Time
Array Functions Array Functions
Array List Array Functions List1
Array Function List Array Functions List2
Math Functions Math Functions
PHP MYSQL Functions PHP Mysql Functions
File Handling File Handling
Error Handling Error Handling
DB Size DB Size
PHP Mail PHP Mail
String Tokens String Tokens
String Functions String Functions
String Functions List String Functions List1
String Functions List2 String Functions List2
Session Functions Session Functions
Cookies Functions Cookies Functions
Form Variables Form Variables
Running PHP from JS Running PHP from JS
Array To JS Array To JS
JS Array Array to PHP
Encryption Encryption
Common Header Common Header
Forums Ask Your Doubts
Scraps More about PHP
Feedback Feedback
 




mysql_field_seek Function in PHP


Tutorials »Php »

Topic

What is mysql_field_seek() function in PHP?
How does mysql_field_seek works?




Explanation

mysql_field_seek function points to a specified field in the resultset.

Syntax

int mysql_field_seek ( resource result, int field_offset)

Returns TRUE on success, or FALSE and a warning on search failure.

mysql_field_seek() moves the internal pointer in a result set returned by mysql_query() function to a specific field search.

Internal Pointer is moved to specific field based on the search value of field_offset. Field offsets for the first field is '0', second is '1' and so on.

Example:


<?php

// Attempt to connect to the default database server
$link = mysql_connect("mysql_host", "mysql_user", "mysql_password")
or die ("Could not connect");

//select database
$db_select = mysql_selectdb("mydb",$link);

//returns result set on executing the query
$result=mysql_query("select * from user",$link);

mysql_field_seek($result,3);
print_r(mysql_fetch_field($result));
mysql_close($link);

?>



In the above example mysql_query() executes simple query and returns search result set. Result set is passed as the first arguments and field index of the result set which is to be pointed is passed as the second arguments to the mysql_field_seek function for the purpose of internal pointer to be moved to the specified field.

After the pointer is moved to the specified field , we can perform any operation on the field.

In the above code after the pointer is moved to the fourth field based on field offset 3, mysql_fetch_field() function is executed and the field information is displayed.

RESULT:

stdClass Object (
[name] => description
[table] => user
[def] =>
[max_length] => 0
[not_null] => 0
[primary_key] => 0
[multiple_key] => 0
[unique_key] => 0
[numeric] => 0
[blob] => 1
[type] => blob
[unsigned] => 0
[zerofill] => 0
)


See also: mysql_fetch_field()





Other Links

web hosting