Jump to content

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


Plazman65

Recommended Posts

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.";



}
?>
Link to comment
Share on other sites

actually, i think it's simply a matter of misplaced curly brackets. try this and see if it helps:
[code]
<?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.";
    }
}
?>

[/code]

i really haven't changed any code, just cleaned it up a little
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.