Jump to content


Photo

a lot of ifs and elses, I need a little guidance


  • Please log in to reply
2 replies to this topic

#1 Plazman65

Plazman65
  • Members
  • PipPipPip
  • Advanced Member
  • 46 posts

Posted 12 April 2006 - 03:24 PM

Good Morning, I am trying to get this page to work. What I need to do is,
if members exceed the amount entered it stopps processing and says "you have succeeded the number of.."
then if it goes past that but it they already have that job in their favorites for it to say " hey you its already in there" and then if it goes past that then goes ahead and enters inserts the data.
It doing everything but the unique job part. Does anyone see whats wrong?
I appreciate the help. Thanks, Michelle


<form action="<?php echo $editFormAction; ?>" method="POST" name="form1" class="style1" id="form1">
<?php
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if
(
($_SESSION['mem_type']=="standard" && $_SESSION['count']>=5)||
($_SESSION['mem_type']=="silver" && $_SESSION['count']>=10)||
($_SESSION['mem_type']=="gold" && $_SESSION['count']>=25)){
echo "You have exceeded your maximum number of Departments. ".
"Please edit your departments or consider upgrading your account.";
}

else
$st = mysql_query("SELECT ,username,depid FROM mydepartments WHERE depid = '$posted_depid' AND username='MM_Username'");
$recs = mysql_num_rows($st);
$row = mysql_fetch_array($st);
if ($recs >=1)

echo "You already have this department in your favorites";


else
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO mydepartments (username, depid, mem_type) VALUES (%s, %s, %s)",
GetSQLValueString($_POST['username2'], "text"),
GetSQLValueString($_POST['depid2'], "int"),
GetSQLValueString($_POST['textfield'], "text"));

mysql_select_db($database_jobs, $jobs);
$Result1 = mysql_query($insertSQL, $jobs) or die(mysql_error());


if (isset($_SERVER['QUERY_STRING']))
echo"Your department has been successfully added.";



}
?>

#2 obsidian

obsidian
  • Staff Alumni
  • Advanced Member
  • 3,202 posts
  • LocationSeattle, WA

Posted 12 April 2006 - 04:09 PM

actually, i think it's simply a matter of misplaced curly brackets. try this and see if it helps:
<?php
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) 
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);

if (($_SESSION['mem_type']=="standard" && $_SESSION['count']>=5) ||
    ($_SESSION['mem_type']=="silver" && $_SESSION['count']>=10) ||
    ($_SESSION['mem_type']=="gold" && $_SESSION['count']>=25)) 
}
  echo "You have exceeded your maximum number of Departments. ".
       "Please edit your departments or consider upgrading your account.";
} else {
  $st = mysql_query("SELECT ,username,depid FROM mydepartments WHERE depid = '$posted_depid' AND username='MM_Username'");
  $recs = mysql_num_rows($st);
  $row = mysql_fetch_array($st);
  if ($recs >=1)
      echo "You already have this department in your favorites";
  elseif ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
        $insertSQL = sprintf("INSERT INTO mydepartments (username, depid, mem_type) VALUES (%s, %s, %s)", GetSQLValueString($_POST['username2'], "text"), GetSQLValueString($_POST['depid2'], "int"), GetSQLValueString($_POST['textfield'], "text"));
        mysql_select_db($database_jobs, $jobs);
        $Result1 = mysql_query($insertSQL, $jobs) or die(mysql_error());
        
        if ($Result1)
            echo"Your department has been successfully added.";
    }
}
?>


i really haven't changed any code, just cleaned it up a little
You can't win, you can't lose, you can't break even... you can't even get out of the game.

<?php
while (count($life->getQuestions()) > 0)
{   $life->study(); } ?>
  LINKS: PHP: Manual MySQL: Manual PostgreSQL: Manual (X)HTML: Validate It! CSS: A List Apart | IE bug fixes | Zen Garden | Validate It! JavaScript: Reference Cards RegEx: Everything RegEx

#3 Plazman65

Plazman65
  • Members
  • PipPipPip
  • Advanced Member
  • 46 posts

Posted 13 April 2006 - 12:47 AM

Thanks for your help, If the number of jobs exceeds then it says hey you cant do that , if its added it says its added. The checking for unique part though it isnt catching that. Any ideas?
Thanks, Michelle




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users