Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Jul 2005
    Posts
    342
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question How to Reference a Table Row without using Index?

    Hi,
    I need to reference specific rows in a table without using row index because my table is sortable, so row is useless because it can change anytime. Is there a way to reference it using name or id? Is there a better way? I don't want to use a different id for each row.

    Many thanks.

  • #2
    Senior Coder missing-score's Avatar
    Join Date
    Jan 2003
    Location
    UK
    Posts
    2,194
    Thanks
    0
    Thanked 0 Times in 0 Posts
    To reference specific rows you must have something that is unique... Why are you against using a unique key field? If you set the Primary Key to "AUTO_INCREMENT" it will automatically go up every time a new row is inserted and you can always reference a specific row...

    I know you asked for another method but there isn't really any way except using some piece of unique data in each row, and seeing as the UNIQUE KEY() is there for that reason, I dont see why you shouldnt use it.

  • #3
    Regular Coder Element's Avatar
    Join Date
    Jul 2004
    Location
    Lynnwood, Washington, US
    Posts
    855
    Thanks
    2
    Thanked 2 Times in 2 Posts
    Quote Originally Posted by dealmaker
    Hi,
    I need to reference specific rows in a table without using row index because my table is sortable, so row is useless because it can change anytime. Is there a way to reference it using name or id? Is there a better way? I don't want to use a different id for each row.

    Many thanks.
    PHP Code:
    mysql_query("SELECT * FROM table WHERE id='"$id ."', username='".$username."' LIMIT 1"); 
    and yes, you can use only one of those, id or username.

  • #4
    Regular Coder
    Join Date
    Jul 2005
    Posts
    342
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Oh, sorry, wrong forum. it's supposed to be in Javascript. Please delete this thread.


  •  

    Posting Permissions

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