Jump to content

Problem with echo and if statements


betportal

Recommended Posts

Hey guys,

 

What I want: I would like to change a text as regard the level of access of the visitor. The visitors have level 0, member level 1. Thus, if the person is a visitor (level 0) he will see "to view the content please register", otherwise, if the person is already a member (level 2) he will see the content "Today's joke is....".

 

I am very noob in php and I've started coding something (my website in under Nuked-Klan) just to try to figure out if the code is working and I still have errors.

 

How can I make this kind of code? I know it's basic but I am too noob

 

Thank you

<?php

global $user

//opentable();

if ( $user[1] == 0 )
{ 
echo "NO MEMBER DETECTED 0";
}

if ( $user[1] == 1 )
{ 
echo "MEMBER DETECTED 1";
} 

if ( $user[1] == 9 )
{ 
echo "ADMIN DETECTED 9"
}

//closetable();

?>

 

Link to comment
https://forums.phpfreaks.com/topic/205067-problem-with-echo-and-if-statements/
Share on other sites

I would like a code for this :

 

"I would like to change a text as regard the level of access of the visitor . The visitors have level 0, member level 1. Thus, if the person is a visitor (level 0) he will see "to view the content please register", otherwise, if the person is already a member (level 2) he will see the content "Today's joke is...."."

 

 

I would like a code for this :

 

"I would like to change a text as regard the level of access of the visitor . The visitors have level 0, member level 1. Thus, if the person is a visitor (level 0) he will see "to view the content please register", otherwise, if the person is already a member (level 2) he will see the content "Today's joke is...."."

 

I once used this statement to let a user "feature" themselves or remove themselves from the list:

 

$feat_res = mysql_query("SELECT DISTINCT User FROM UserTable WHERE User='$_SESSION[user]' AND Featured=1", $connection);
if (mysql_num_rows($feat_res) == 1 ) {
$_SESSION['Featured'] = true;
echo '<a href="featureMe.php">Unfeature Me</a><br />'."\r\n";
} else {
$_SESSION['Featured'] = false;
echo '<a href="featureMe.php">Feature Me!</a><br />'."\r\n";
}

 

Might that be what your looking for? Just test for your condition and execute different scenarios

Hi thank you !

 

My database is called "datab1" -> "nuked_users" -> "level"

 

How can I transform it into your statements?

 

I'm not going to do it for you :)

Google php mysql functions

If you can't find what you need come back and we'll go from there

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.