getting data from rows containing $code
Moderator: General Moderators
getting data from rows containing $code
I have a mysql database with a table that contains account information. Users can have up to 5 accounts and each one shares a value called regkey. I want to find and echo the name of all the users that have the same regkey value.
How would I do this?
How would I do this?
im new to this
Im pretty new to this can you give me an example script?
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Ok this doesn't explain what I need I can't figure out how to do this.
I say I get the table down to:
username|key
name1|key1
name2|key2
name3|key1
ok then i want a way so that if I tell it key 1 it would give me name1 and name 3 or if i gave it key2 i would get name 2.
Can someone just explain how I would do this?
I say I get the table down to:
username|key
name1|key1
name2|key2
name3|key1
ok then i want a way so that if I tell it key 1 it would give me name1 and name 3 or if i gave it key2 i would get name 2.
Can someone just explain how I would do this?
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
table structure
|username|password|email|realname|regkey|
and I want to find all the usernames with a particular regkey
and I want to find all the usernames with a particular regkey
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
The manual will give you some more examples on querying your database based on certain fields.
http://dev.mysql.com/doc/refman/5.0/en/select.html
Some other links you should read over, mysql_connect(), mysql_query(), mysql_fetch_assoc(), mysql_num_rows(), mysql_real_escape_string()
Code: Select all
SELECT * FROM `your_table_name_here` WHERE `regkey` = 'dsf2432dsf'ok never mind but now I got the infomation I needed but and I am using this code
Code: Select all
$sql="SELECT username FROM ".$table." WHERE regkey = '".$_GET['regkey']."'";
$qry = mysql_query($sql);
while ($row = mysql_fetch_array ($qry))
{
echo $row[0];
}
and this gives me one of the entries but I should be getting 2 how do I change this so I can get 2?