Jump to content

[SOLVED] Should I use an array...or...


Aureole

Recommended Posts

The below is all fine and dandy and it works but I need more than one value for $allowed. I think I need to use an array but I'm new to PHP and haven't encountered an array before, searching Google yielded no results that helped.

 

I just need $allowed to have more than one value.

 

<?php
$allowed = "5";
if ($member['id'] == $allowed) {
echo "Show the code to add news stories...";
} else {
echo "Show nothing...";
} ?>

Link to comment
Share on other sites

yeah you could do $allowed = array("1","2","3","4","5",...); but  i have a question for your uses, is allowed the UserID from the MySQL table and you have an allowed/disallowed users on a certain section? if so why not just add another field to the members table called security level and based on that integer value it determines if they can see certain content

Link to comment
Share on other sites

I'm using IPB SDK, I used get_advinfo which gives me...

 

Array
(
    [id] => 1
    [name] => no_comment
    [mgroup] => 4
    [email] => matthias@pc-intern.com
    [joined] => 1052760073
    [ip_address] => 80.129.253.245
    [posts] => 7156
    [title] =>
    [allow_admin_mails] =>
    [time_offset] => 1
    [hide_email] => 0
    [email_pm] => 0
    [email_full] =>
    [skin] => 12
    [warn_level] => 0
    [warn_lastwarn] => 0
    [language] => 2
    [last_post] => 1179530411

 

And a LOT more I could use the mgroup ( $member['mgroup'] ) instead I guess that would be better but still how would I do it?

 

 

Link to comment
Share on other sites

I tried using...

 

<?php
$allowed = array("1", "5");

if ($member['id'] == $allowed) {
echo "<a href=\"news/submitnews.php\" title=\"Submit News\" class=\"newstitle\" onclick=\"return overlay(this, 'submitnews')\">
<img src=\"img/submit.png\" width=\"24px\" height=\"24px\" alt=\"Submit\" style=\"margin-right:5px;\" /></a>";

} else {

echo "";
}
?>

 

And me (id = 1) and my friend (id=5) cannot see the button to add news...

Link to comment
Share on other sites

that will work for a few uses, i'm not familiar with this software it probably should be a topic for third party script  help, but i'd still say use a mysql field for security level (i'm assuming u have a mysql table for users)

 

However if you use what you are doing now image doing it for 1000+ users

Link to comment
Share on other sites

Even if my Website grows and grows and we have thousands of users there will only be a few people who can add news, so it doesn't really matter...and the array() I tried didn't work and this shouldn't really be a topic for the third party script, if I was having problems with the script then maybe yes but I'm not I just didn't know hot to make $allowed have more than one value so...

Link to comment
Share on other sites

How come the array isn't working,

 

If this worked before...

 

<?php
$allowed = "1";

if ($member['id'] == $allowed) {
echo "<a href=\"news/submitnews.php\" title=\"Submit News\" class=\"newstitle\" onclick=\"return overlay(this, 'submitnews')\">
<img src=\"img/submit.png\" width=\"24px\" height=\"24px\" alt=\"Submit\" style=\"margin-right:5px;\" /></a>";
} else {
echo "";
} ?>

 

Then how come this doesn't...

 

<?php
$allowed = array('1', '5', '2', '3');

if ($member['id'] == $allowed) {
echo "<a href=\"news/submitnews.php\" title=\"Submit News\" class=\"newstitle\" onclick=\"return overlay(this, 'submitnews')\">
<img src=\"img/submit.png\" width=\"24px\" height=\"24px\" alt=\"Submit\" style=\"margin-right:5px;\" /></a>";
} else {
echo "";
} ?>

Link to comment
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.