Jump to content

joeholdcroft

New Members
  • Posts

    4
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

joeholdcroft's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Please ignore, just my luck to figure it out as soon as I make a post. Thanks :)
  2. Ok, so for a while I've been shooting myself over this script that I can't get to work, let me explain what I want it to do as simply as I can. I have a users table, with a column where the categories each user can post news in are stored, seperated by a comma, the category IDs are stored, not the category names. I want this script to first, check of the logged in user is an administrator, or a writer, if they are a writer, I want it to: Search through the users table for their user information, get the categories column and then display each of the categories they are allowed to post in in a drop-down select menu, and only the ones that have the ID in that column of their row on the users table, NOT all categories. And if they are an admin, it just displays all the categories in a drop-down menu. I have been fiddling with this for ages, but can't get it to work. The user i'm logged in as has the value "1, 3" for his categories column, and is a writer. So theoretically, it should show just Test 1 and Test 3 in the drop down menu, when in reality it shows Test 1(id=1), Test 2(id=2) and Test 3(id=3). This is the code: [code]        <select name="category" class="form" id="category"> <?php     $userid = $_SESSION['userid'];     if($_SESSION['rank'] == 'writer') {     $result = mysql_query("SELECT categories FROM users WHERE id='$userid'") or die(mysql_error());     $usrcat = explode(",", $usrcat);         foreach($usrcat as $cat) {         $cat = trim($cat);         $result = mysql_query("SELECT * FROM categories WHERE id='$cat'") or die(mysql_error());             while($eachcat = mysql_fetch_array($result)) {             $catid = $eachcat['id'];             $catname = $eachcat['name'];             echo "<option value=\"$catid\">$catname</option>";             }         }     }     elseif($_SESSION['rank'] == 'admin') {     $result = mysql_query("SELECT * FROM categories") or die(mysql_error());         while($eachcat = mysql_fetch_array($result)) {         $catid = $eachcat['id'];         $catname = $eachcat['name'];         echo "<option value=\"$catid\">$catname</option>";         }     }         ?>           </select>[/code] Many thanks in advance guys, I'm intrigued as to what I'm doing wrong here, I don't get any error messages as such, just it shows all categories except just the 2 I want. Thanks! Joe
  3. Thanks. Yeah I know that much, but then how do i store those variables in another file permanently?
  4. Is there a way to make a form input into a permanent variable, that can then be used on any other pages as long as the file they're stored in is included. For example: An installation file: the first page is where the user would input their MySQL Host, Username, Password and Database. Then I want the page to save this information to a config.php file, which can then be included on all the pages that need to correspond with the database using this information. Then on the second installation page, the tables would be inserted to the database, ect. Just the only thing i'm not sure how to do is the permanent variable storing, how would I go about this? Many thanks!! :)
×
×
  • 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.