Jump to content

Php if command Help


Dsnowdon

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.