Jump to content

Recommended Posts

Basicaly i want to have certian links to apeer on on the nav bar when a user with the level on lets say 1 to

 

i have done this before and i cant remember the code so i need some help

 

There level is in  a database called dalsno3_db

the table is called members

 

 

i know you will need a were first name in the database =  $_SESSION['SESS_FIRST_NAME'];

so for that could you use

mysql_query("SELECT * FROM members

  WHERE firstname = '$_SESSION['SESS_FIRST_NAME']'");

 

'$_SESSION['SESS_FIRST_NAME']' = $firstname

 

also would this work

if ($firstname["level"]!=='1') {

do something

}

 

i am quite new to php

 

thanks dale

Link to comment
https://forums.phpfreaks.com/topic/202749-php-if-command-help/
Share on other sites

Well, first name seems a poor choice to use for a unique identifier. Typically you would use a user ID.

 

Example code:

$user_id = $_SESSION['user_id'];
$query = "SELECT * FROM `users` WHERE user_id = '$user_id'";
$result = mysql_query($query);
$user = mysql_fetch_assoc($result);

//....

echo "Hello {$user['first_name']}:<br /><br />\n";
echo "Select from the following links:<br /><br />\n";
echo "<a href="1.php">Link 1</a><br />\n";
echo "<a href="2.php">Link 2</a><br />\n";
echo "<a href="3.php">Link 3</a><br />\n";
//Only display link four for users of level 1
if($user['level']=='1')
{
    echo "<a href="4.php">Link 4</a><br />\n";
}

Link to comment
https://forums.phpfreaks.com/topic/202749-php-if-command-help/#findComment-1062633
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.