/    Sign up×
Community /Pin to ProfileBookmark

getting value in fk_t_directories

function foreach_db($name = ‘default’) {
global $queries;
if (!$queries[$name]) return False;
$line = mysql_fetch_object($queries[$name][0]);
f (++$queries[$name][1] >= $queries[$name][2]) {
mysql_free_result($queries[$name][0]);
$queries[$name] = False;
}
return $line;
}

actually i dont no how to get value for eg
$names = array();
SELECT u.name,u.sys_pk FROM t_user u INNER JOIN tr_directories_user r ON r.fk_t_user=u.sys_pk WHERE r.fk_t_directories=’517′ //how i can pass value
thats why i use $r->sys_pk and after this querry

while($r = foreach_db()) {
$names[$r->sys_pk] = $r;
}
please guide me how to pass value through querry

this is the table t_user
CREATE TABLE t_user (
sys_pk int(11) NOT NULL auto_increment,
name text,
fk_t_directories int(11) NOT NULL default ‘0’,
PRIMARY KEY (sys_pk),
KEY Key_fk_t_directories (fk_t_directories)
) TYPE=MyISAM;

INSERT INTO t_user VALUES (12,’acursora’,951);
INSERT INTO t_user VALUES (8,’VD’,860);
INSERT INTO t_user VALUES (11, ‘CAD’,99);

CREATE TABLE tr_directories _user(
sys_pk int(11) NOT NULL auto_increment,
fk_t_directories int(11) NOT NULL default ‘0’,
fk_t_user int(11) NOT NULL default ‘0’,
PRIMARY KEY (sys_pk),
UNIQUE KEY fk_t_directories (fk_t_directories,fk_t_user),
KEY Key_fk_t_directories (fk_t_directories),
KEY Key_fk_t_user (fk_t_user))

INSERT INTO t_directories VALUES (12,199,37)
INSERT INTO t_directories VALUES (8,111,11)
INSERT INTO t_directories VALUES (11,69,11)

how i can pass the value in fk_t_directories as i dont want to hard code

i used join qerry so that when i select directories from form i can get user name

hopefully u understand my situation

thanks in advance

to post a comment
PHP

0Be the first to comment 😎

×

Success!

Help @zuzupus spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.27,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...