php - Mysql INNER JOIN and Resource #9 -
i working on ucp(user control panel) user loggs in unique id given @ registration. problem have 2 tables in database:
serverplayers - holds user id , name , of info
and
vehicles - holds vehicle owner , vehicle model.
so need connect 2 users "username".i tried mysql inner join this.
$car = mysql_query('select vehicles.vowner, vehicles.vmodel vehicles inner join serverplayers on vehicles.vowner = serverplayers.user vehicles.vowner = '.$ro['user'].'');
after recourse #9, read it's not error it's result empty?i may have error's or problems in mysql query please tell whats wrong.
but what's problem think vehicle connected it's owner's name , doesn't contain userid.so need show user car has connecting username vowner.i'm not bright boy when comes mysql or php i'm learning , came across thing mysql inner joins think usefull(but main reason don't want recode whole server , ucp).
vehicles:
serverplayers:
serverplayers table http://img94.imageshack.us/img94/3369/qebq.png
i'm not sure $ro['user']
is, sounds id based on question. in case switch vehicles.vowner
serverplayers.userid
in comparison. highly recommend changing schema vowner
is id , not username (what if username changes in 1 of tables?) doesn't need join on serverplayers anything.
the "resource" mysql results resource. can't out of looking @ -- need run fetch operations on it:
$row = mysql_fetch_assoc($car);
i recommend using pdo or mysqli on deprecated ext/mysql.
Comments
Post a Comment