Page 1 of 1
getting data from rows containing $code
Posted: Sun Aug 26, 2007 3:56 pm
by X3no
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?
Posted: Sun Aug 26, 2007 4:03 pm
by feyd
A basic SELECT query?
im new to this
Posted: Sun Aug 26, 2007 4:04 pm
by X3no
Im pretty new to this can you give me an example script?
Posted: Sun Aug 26, 2007 4:07 pm
by feyd
There are plenty of examples throughout our forums, the manual(s) and the web. Sorry, no.
I tried
Posted: Sun Aug 26, 2007 4:12 pm
by X3no
I tried to find an example before I posted but couldn't find one.
Posted: Sun Aug 26, 2007 4:15 pm
by Fiarr
I was wondering the same thing....
I havn't been able to find the answer since I don't know what to search for....
Im completely new to php.
Posted: Sun Aug 26, 2007 4:29 pm
by John Cartwright
Posted: Sun Aug 26, 2007 5:07 pm
by Fiarr
And this will let me search the database for whatever I specify??
Posted: Sun Aug 26, 2007 5:17 pm
by X3no
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?
Posted: Sun Aug 26, 2007 5:35 pm
by John Cartwright
Whats your table structure?
table structure
Posted: Sun Aug 26, 2007 5:40 pm
by X3no
|username|password|email|realname|regkey|
and I want to find all the usernames with a particular regkey
Posted: Sun Aug 26, 2007 5:46 pm
by John Cartwright
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
Code: Select all
SELECT * FROM `your_table_name_here` WHERE `regkey` = 'dsf2432dsf'
Some other links you should read over,
mysql_connect(),
mysql_query(),
mysql_fetch_assoc(),
mysql_num_rows(),
mysql_real_escape_string()
Posted: Sun Aug 26, 2007 6:20 pm
by X3no
could I change * to username so that it would give me the usernames with that key?
Posted: Sun Aug 26, 2007 7:33 pm
by X3no
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?