Zen Cart Logo
Forums / General Questions / To get the $admin_name in the categories.php

To get the $admin_name in the categories.php

Locked

Views: 1,863

Results 1 to 7 of 7
This thread is locked. New replies are disabled.
28 Feb 2008, 5:07 PM
#1
juniorphp avatar

juniorphp

New Zenner

Join Date:
Feb 2008
Posts:
8
Plugin Contributions:
0

To get the $admin_name in the categories.php

I want to get the admin name after they log in,
and use this variable in the categories.php

is it a session variable?

I tried to echo $admin_name; in categories, but it didn't work:shocking:

28 Feb 2008, 8:59 PM
#2
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: To get the $admin_name in the categories.php

juniorphp:

I want to get the admin name after they log in,
and use this variable in the categories.phpWhy?

juniorphp:

is it a session variable?

I tried to echo $admin_name; in categories, but it didn't work:shocking:

You'd have to look it up from the database by referencing $_SESSION['admin_id']

29 Feb 2008, 6:00 AM
#3
juniorphp avatar

juniorphp

New Zenner

Join Date:
Feb 2008
Posts:
8
Plugin Contributions:
0

Re: To get the $admin_name in the categories.php

I got it, thank you.

Also, i want to know the location of code for categories listing in categories.php

thank a lot~

29 Feb 2008, 7:17 AM
#4
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: To get the $admin_name in the categories.php

juniorphp:

I got it, thank you.

Also, i want to know the location of code for categories listing in categories.php

thank a lot~

You're changing topics now, but I think what you're looking for is /admin/includes/modules/category_product_listing.php

29 Feb 2008, 7:51 AM
#5
juniorphp avatar

juniorphp

New Zenner

Join Date:
Feb 2008
Posts:
8
Plugin Contributions:
0

Re: To get the $admin_name in the categories.php

I can get the admin_id

echo $_SESSION['admin_id'];

but I still can't extract the admin name from the SQL by the code

{

$result = $db->Execute("select admin_name from " . TABLE_ADMIN . " where admin_id = '" .$_SESSION['admin_id'] . "'");

$row = mysql_fetch_assoc($result);

echo $row['Variable_name'];

}

it give Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in C:~...

how can i fix it ?

2 Mar 2008, 6:47 AM
#6
juniorphp avatar

juniorphp

New Zenner

Join Date:
Feb 2008
Posts:
8
Plugin Contributions:
0

Re: To get the $admin_name in the categories.php

as I can get the admin_id after login in

echo $_SESSION['admin_id'];

but I still can't extract the admin name from the SQL by the code

{

$result = $db->Execute("select admin_name from " . TABLE_ADMIN . " where admin_id = '" .$_SESSION['admin_id'] . "'");

$row = mysql_fetch_assoc($result);

echo $row['Variable_name'];

}

it give Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in C:~...

how can i fix it ?

2 Mar 2008, 8:24 AM
#7
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: To get the $admin_name in the categories.php

Repeating the same post again isn't very helpful to anybody.
Posting more information about things you've tried will usually get you faster (and definitely friendlier) answers.

juniorphp:

but I still can't extract the admin name from the SQL by the code

{

$result = $db->Execute("select admin_name from " . TABLE_ADMIN . " where admin_id = '" .$_SESSION['admin_id'] . "'");

$row = mysql_fetch_assoc($result);

echo $row['Variable_name'];

}

  1. Why would you expect $row['Variable_name"] to match anything in the original query?

  2. If you're going to use the Zen Cart functions to query the database, you need to be consistent in doing so.
    You'll find it much easier to use this:

$result = $db->Execute("select admin_name from " . TABLE_ADMIN . " where admin_id = '" . $_SESSION['admin_id'] . "'");

echo $result->fields['admin_name'];