Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Use Text ID

Status
Not open for further replies.

alrdairmn

Technical User
Oct 9, 2004
5
US
Hi,

I'm new to PHP -- How do I create a table that has a TEXT ID in mySQL? In other words, what query/how do I make it so the address mydomain.com/page.php?username=jsmith (instead of something like mydomain.com/page.php?id=12)? Also, what would be the PHP query to pull up a record with such a table?

Thanks for any insights.
 
when you create the table, just create it with a character datatype for the username field

text is not recommended (it's too big), use something like VARCHAR(25)

CREATE TABLE myusers
( username varchar(25) not null primary key
, foo integer
, bar varchar(255)
)

then when you want to select someone, the query is

SELECT foo, bar
FROM myusers
WHERE username='$username'

here $username is the php variable that comes from the url

rudy
SQL Consulting
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top