SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Guru Dashman's Avatar
    Join Date
    Jan 2006
    Location
    Manchester, UK
    Posts
    627
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Use of mysql_data_seek?

    Hi guys....

    I have seen mysql_data_seek being used in a script. I have looked at the manual, but cannot really understand the function's use.
    Could someone please explain how and why it should be used, possibly with a more simple example than used in the manual?

    Cheers,
    D

  2. #2
    SitePoint Wizard siteguru's Avatar
    Join Date
    Oct 2002
    Location
    Scotland
    Posts
    3,629
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    When data is returned from a MySQL DB then it would be like this ...
    Code:
    Row	Field1	Field2
    0	data1	data2
    1	data3	data4
    2	data5	data6
    3	data7	data8
    4	data9	data10
    The row pointer is the number in the Row column. Using mysql_data_seek() lets you define which row to retrieve.
    Ian Anderson
    www.siteguru.co.uk

  3. #3
    SitePoint Guru Dashman's Avatar
    Join Date
    Jan 2006
    Location
    Manchester, UK
    Posts
    627
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok....thanks....so, would I use it to find a row with a specific ID then, or would it mainly be used in lookup tables? ie: ids associated with another parent id for example? does that make sense?

  4. #4
    SitePoint Wizard siteguru's Avatar
    Join Date
    Oct 2002
    Location
    Scotland
    Posts
    3,629
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    This function purely and simply lets you define which ROW number to go to - it has no idea about what is actually IN that row. An example of this would be that you would loop through the result to do something, use mysql_data_seek($result, 0) to go back to the beginning, then loop through the result again to do other stuff.

    To do what you want it would make better sense to structure your SQL query to just return the data you need.
    Ian Anderson
    www.siteguru.co.uk


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •