Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-31-2005, 12:09 AM   PM User | #1
dealmaker
Regular Coder

 
Join Date: Jul 2005
Posts: 342
Thanks: 0
Thanked 0 Times in 0 Posts
dealmaker has a little shameless behaviour in the past
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.
dealmaker is offline   Reply With Quote
Old 12-31-2005, 12:27 AM   PM User | #2
missing-score
Senior Coder


 
missing-score's Avatar
 
Join Date: Jan 2003
Location: UK
Posts: 2,194
Thanks: 0
Thanked 0 Times in 0 Posts
missing-score is on a distinguished road
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.
missing-score is offline   Reply With Quote
Old 12-31-2005, 12:28 AM   PM User | #3
Element
Regular Coder

 
Element's Avatar
 
Join Date: Jul 2004
Location: Lynnwood, Washington, US
Posts: 855
Thanks: 2
Thanked 2 Times in 2 Posts
Element is an unknown quantity at this point
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.
Element is offline   Reply With Quote
Old 12-31-2005, 12:39 AM   PM User | #4
dealmaker
Regular Coder

 
Join Date: Jul 2005
Posts: 342
Thanks: 0
Thanked 0 Times in 0 Posts
dealmaker has a little shameless behaviour in the past
Oh, sorry, wrong forum. it's supposed to be in Javascript. Please delete this thread.
dealmaker is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:22 AM.


Advertisement
Log in to turn off these ads.