Fetching MySQL Information

07-23-07, 12:51 PM
|
|
Newbie Coder
|
|
Join Date: May 2005
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
|
Fetching MySQL Information
I want to fetch domains under a specific user ID in a table, how do I do this?
Here is the MySQL
sql Code:
CREATE TABLE `users` ( `id` int(5) NOT NULL AUTO_INCREMENT, `login` varchar(15) DEFAULT '0', `password` varchar(15) DEFAULT '0', `domains` varchar(15) DEFAULT '0', PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;
So, I want to display the "domains" in the users table for the id. Will be displayed in a table. It wont use login or password in the users table.
Here is an example of what I mean:
http://www.scriptplayground.com/tuto...tch-MySQL-Row/
__________________
VISIT JIVENETWORKS
FREE SOFTWARE, ARTICLES, NEWS AND MORE
ITS ALL FREE!!!
Last edited by Nico; 07-23-07 at 01:16 PM.
|

07-23-07, 01:20 PM
|
 |
Community Leader
|
|
Join Date: Sep 2005
Location: Spain
Posts: 8,075
Thanks: 11
Thanked 88 Times in 83 Posts
|
|
|
|

07-23-07, 02:45 PM
|
|
Newbie Coder
|
|
Join Date: May 2005
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
doesnt work, i get "Unknown column 'XX' in 'where clause'" eror
__________________
VISIT JIVENETWORKS
FREE SOFTWARE, ARTICLES, NEWS AND MORE
ITS ALL FREE!!!
|

07-23-07, 02:50 PM
|
 |
Community Leader
|
|
Join Date: Sep 2005
Location: Spain
Posts: 8,075
Thanks: 11
Thanked 88 Times in 83 Posts
|
|
You have to replace the XX with the actual ID you want to fetch.
|

07-23-07, 02:51 PM
|
|
Newbie Coder
|
|
Join Date: May 2005
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I did it like this, but it shows all of them and not a specific login row
__________________
VISIT JIVENETWORKS
FREE SOFTWARE, ARTICLES, NEWS AND MORE
ITS ALL FREE!!!
Last edited by Christian; 07-24-07 at 11:45 PM.
Reason: Please use [PHP] tags when posting PHP code.
|

07-23-07, 03:05 PM
|
 |
Community Leader
|
|
Join Date: Sep 2005
Location: Spain
Posts: 8,075
Thanks: 11
Thanked 88 Times in 83 Posts
|
|
Use my code, and replace the XX with the login ID.
|

07-23-07, 03:13 PM
|
|
Newbie Coder
|
|
Join Date: May 2005
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
if XX is $_SESSION["login"], how would I include it then
__________________
VISIT JIVENETWORKS
FREE SOFTWARE, ARTICLES, NEWS AND MORE
ITS ALL FREE!!!
|

07-23-07, 03:19 PM
|
|
Newbie Coder
|
|
Join Date: May 2005
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
still getting
Unknown column 'alpha' in 'where clause'
[php]$user_id = $_SESSION["login"];
$query = mysql_query("SELECT domains FROM users WHERE id = $user_id LIMIT 1") OR die(mysql_error());
$userinfo = mysql_fetch_array($query);
echo $userinfo['domains'];/php]
__________________
VISIT JIVENETWORKS
FREE SOFTWARE, ARTICLES, NEWS AND MORE
ITS ALL FREE!!!
Last edited by Christian; 07-24-07 at 11:46 PM.
Reason: Please use [PHP] tags when posting PHP code.
|

07-23-07, 03:20 PM
|
 |
Community Leader
|
|
Join Date: Sep 2005
Location: Spain
Posts: 8,075
Thanks: 11
Thanked 88 Times in 83 Posts
|
|
What does $_SESSION['login'] hold? The row ID or the value from the login field?
If it's the ID, try:
And if it's the value from the login field, try:
|

07-23-07, 03:30 PM
|
|
Newbie Coder
|
|
Join Date: May 2005
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
i insert more then 1 domain my nulling password and id and using insert for login and domains, so I can have multiple domain enteries per login
way u did it, is only showing 1 domain, i want to show unlimited domains
__________________
VISIT JIVENETWORKS
FREE SOFTWARE, ARTICLES, NEWS AND MORE
ITS ALL FREE!!!
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|