PDA

View Full Version : getting info from a db table?


Neo
04-13-2002, 11:17 PM
How would I go about getting infomation like the way you can with $bbuserinfo. But with another table?

mr e
04-14-2002, 05:24 AM
Well the way I do it is go into PHPMyAdmin and look at the different tables and see which one has the info you want the do

$variable=$DB_site->query_first("SELECT * FROM INSERTTABLEHERE");

Neo
04-14-2002, 05:28 AM
Ummmm... I know how to do that what I want to be able to do is call information like the $bbuserinfo does.

examples:
$bbuserinfo[username]
$bbuserinfo[userid]

and so no but with a different table

DjSap
04-14-2002, 06:32 AM
well the bbuserinfo query is in session.php, i don't really understand what you are trying to do...if you want to grab extra info to $bbuserinfo from another table then just add ,tablename.* to the query....but if you want to grab a totaly diffrent table that isn't based on userid then you prolly would be better off making a function.

Neo
04-14-2002, 06:54 AM
Umm.. there are ways of doing it without having to make another function... I guess I will have to get off my lazy ass site down and do it. ;)

Reeve of shinra
04-14-2002, 07:39 AM
If you have a variable pulling multiple information from a table, then you can use the variable name with the field name in brackets to have it displayed.

ex:

$myvar query_first("field1, field2, field3");

$myvar[field1]
$myvar[field2]
$myvar[field3]

Or something like that,... I think you catch on to my horribly bad explaination here =P

Neo
04-14-2002, 09:50 PM
Thanks Reeve, but I figured it out after sobering up :)

Neo
04-15-2002, 01:29 PM
$result=$DB_site->query("SELECT * FROM user WHERE userid='1'");
$userinfo=mysql_fetch_array($result);

Admin
04-15-2002, 01:36 PM
Originally posted by neo

$result=$DB_site->query("SELECT * FROM user WHERE userid='1'");
$userinfo=mysql_fetch_array($result);

Or just
$userinfo = $DB_site->query_first("SELECT * FROM user WHERE userid=1");