...

View Full Version : How to Reference a Table Row without using Index?



dealmaker
12-31-2005, 12:09 AM
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.

missing-score
12-31-2005, 12:27 AM
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.

Element
12-31-2005, 12:28 AM
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.


mysql_query("SELECT * FROM table WHERE id='". $id ."', username='".$username."' LIMIT 1");

and yes, you can use only one of those, id or username.

dealmaker
12-31-2005, 12:39 AM
Oh, sorry, wrong forum. it's supposed to be in Javascript. Please delete this thread.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum