1
Horatio
Module getting uid from db
  • 2005/11/26 11:37

  • Horatio

  • Just popping in

  • Posts: 13

  • Since: 2005/7/2 9


Eya,

i am creating a special custom module for a company.

Now I am trying to get the reduction percentage from the database based on the users id. However when using <{$xoops_userid}> it doesnt work.

Here is what i got already:

/* Pulling user elements from db */
$result $xoopsDB->query("SELECT red_perc FROM xappl_users where uid = '1'");

while (
$row $xoopsDB->fetchArray($result)) {
    
$red_perc_out $row['red_perc'];
}

The 1 from uid should off course be the current user.

Also when trying simple <{$xoops_userid}> in the html area it just gives "Object". Does anyone have a clue about how to solve this? I did use an extra connection with the database as I didnt know how to add a connection from XOOPS itself. But I'm working on that already..

All help is appreciated!

2
wtravel
Re: Module getting uid from db

I assume you are you using this code extract in a module page. If you built the page correctly by including the proper header file, you should be able to get the current user ID by using:

$userid = $xoopsUser->getVar('uid');

Best wishes

3
Horatio
Re: Module getting uid from db
  • 2005/11/26 12:04

  • Horatio

  • Just popping in

  • Posts: 13

  • Since: 2005/7/2 9


well i had already been fooling around with the getvar function but i didnt know exactly how to state it.

Added it under the globals and now the whole db-pull works.

Cheers!

Login

Who's Online

460 user(s) are online (357 user(s) are browsing Support Forums)


Members: 0


Guests: 460


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits