GIDForums  

Go Back   GIDForums > Computer Programming Forums > MySQL / PHP Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 14-Aug-2003, 05:11
zuzupus zuzupus is offline
Junior Member
 
Join Date: Jul 2003
Posts: 70
zuzupus is an unknown quantity at this point

join problem


hi,
i created 2 tables and i want to fetch name from t_user having sys_pk from t_directories

CREATE TABLE t_directories (
sys_pk int(11) NOT NULL auto_increment,
sys_del char(1) NOT NULL default 'f',
sys_state tinyint(2) NOT NULL default '0',
sys_dlm timestamp(14) NOT NULL,
sys_klm int(11) NOT NULL default '0',
sys_doc timestamp(14) NOT NULL,
sys_koc int(11) NOT NULL default '0',
fk_t_directories_parent int(11) NOT NULL default '0',
name varchar(50) default NULL,
sort smallint(4) NOT NULL default '0',
bild_path varchar(250) NOT NULL default '',
bild_width smallint(4) NOT NULL default '0',
bild_height smallint(4) NOT NULL default '0',
html_file varchar(250) NOT NULL default '',
info enum('f','t') NOT NULL default 't',
PRIMARY KEY (sys_pk),
KEY key_sys_state (sys_state),
KEY key_sys_dlm (sys_dlm),
KEY key_sys_doc (sys_doc),
KEY Key_fk_t_directories_parent (fk_t_directories_parent),
KEY Key_sort (sort)
) TYPE=MyISAM;

#
# Dumping data for table `t_directories`
#

INSERT INTO t_directories VALUES (1,'f','',20030811151259,1,20020113175903,1,'','IN ACTION',4,'',32,32,'','f');
INSERT INTO t_directories VALUES (570,'f','',20030331101620,1,20021211124003,1,69,' Rolta Import',31,'','','','','f');
INSERT INTO t_directories VALUES (4,'f','',20030811151259,1,20020113175937,1,'','SP ECIALS',6,'','','','','f');


CREATE TABLE t_user (
sys_pk int(11) NOT NULL auto_increment,
sys_del char(1) NOT NULL default 'f',
sys_state tinyint(2) NOT NULL default '0',
sys_dlm timestamp(14) NOT NULL,
sys_klm int(11) NOT NULL default '0',
sys_doc timestamp(14) NOT NULL,
sys_koc int(11) NOT NULL default '0',
user varchar(50) NOT NULL default '',
password varchar(50) default NULL,
admin char(1) default NULL,
name text,
logo_path varchar(250) default NULL,
logo_width smallint(4) default NULL,
logo_height smallint(4) default NULL,
intern char(1) default NULL,
radmin char(1) default NULL,
fk_t_directories int(11) NOT NULL default '0',
PRIMARY KEY (sys_pk),
KEY key_sys_state (sys_state),
KEY key_sys_dlm (sys_dlm),
KEY key_sys_doc (sys_doc),
KEY Key_user (user),
KEY Key_fk_t_directories (fk_t_directories)
) TYPE=MyISAM;

#
# Dumping data for table `t_user`
#

INSERT INTO t_user VALUES (12,'f','',20030505112239,1,20020117130250,1,'dd', 'xxxxx','t','VD DDLust','','','','t','t','');
INSERT INTO t_user VALUES (8,'f','',20030505111943,1,20011122114534,'','vd', 'xxxxx','t','VD VV','5367a5c8aa2c48cf.gif',459,141,'t','t','');
INSERT INTO t_user VALUES (11,'f','',20030504213155,1,20020117125826,1,'bbsc ad','xxxxxx','f','BBS CAD Abteilung','713c587b512ac340.jpg',250,472,'f','f', '');


I used use JOIN for both tables and i want to fetch name in my field when some directory is selcted let say SUCHEN then name should display like VD DD,VD VV,BBS CAD
$names=array();
//SUCHEN have sys_pk is 843 and i dont want to hard code like this plz modify the code
query_db("SELECT u.name FROM t_user u INNER JOIN tr_directories_user r ON r.fk_t_user=u.sys_pk WHERE r.fk_t_directories='843'");//how i can get this value instead of hardcoding 843 how i can pass sys_pk
while($r = foreach_db()) {
$names[$r->sys_pk] = $r->names;//here some problem dont no how to use u.name but when i run above querry in MySQL it works fine
}

so when i select on directory whose sys_pk is 843 so that my Benutzer und Recte field display something like this

Benutzer und Recte: VD DD
VD VV
BBS CAD

and when no cusotmer found simply display No customer found in above field



hope this is enough to get understand
thanks
Attached Images
File Type: jpg dir.jpg (25.7 KB, 36 views)
 
 

Recent GIDBlogMatch IP in CIDR by gidnetwork

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
problem with php5 cgi installation fab13 Apache Web Server Forum 3 19-Nov-2003 09:11
unwanted scrollbar problem kelly001 Web Design Forum 3 24-Oct-2003 10:44
Geforce FX 5600 Ultra problem jenovasbirth Computer Hardware Forum 1 04-Oct-2003 17:00
select problem zuzupus MySQL / PHP Forum 0 15-Aug-2003 07:25
Problem with array norok MySQL / PHP Forum 3 16-Jul-2003 02:08

Network Sites: GIDNetwork · GIDApp · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 00:43.


vBulletin, Copyright © 2000 - 2013, Jelsoft Enterprises Ltd.