Jump to content

What am I missing????


chronister

Recommended Posts

Hey folks,

 

I have been banging my head against the monitor for a while now because of this issue. I am sharing a form between 2 insert functions. I can do this because they only differ by 1 field. I have added a hidden var to tell me which query to run, so that is not the problem.

 

The issue comes when I try not to display the email field's table row.

 

 

<?php if($_GET['view']!=='add_store_team' || $_GET['action']!=='edit_store_team' ){ ?>
  <tr>
    <td nowrap="nowrap"><label for="email">Email Address</label></td>
    <td><input type="text" name="email" id="email" value="<?=$_email ?>"/></td>
  </tr>
  <?php } ?>

 

I am wanting to not display this field when either of 2 vars are passed in the url,

action=edit_store_team

view=add_store_team

 

These are passing correctly. When I drop one of the conditions from the if statement, it works fine. I have dropped each one out and tested it and separately they work, but I cannot get it to work when I have it set up like above.

 

What am I missing here??? Why isn't this working??

 

Thanks in advance for your input.

 

Nate

 

Link to comment
https://forums.phpfreaks.com/topic/65310-what-am-i-missing/
Share on other sites

your if() condition will always be true, because your $_GET['view'] variable can only ever have one value.  let's say $_GET['view'] is 'add_store_team' - the first part of the condition will be false, because it DOES equal 'add_store_team.'  however, the second part will be true because in being equal to 'add_store_team', it's NOT equal to 'edit_store_team.'  see what i mean?

 

you need to change the || operator to &&, such that it will only display the e-mail row if the $_GET['view'] is neither 'add_store_team' nor 'edit_store_team'.  i hope i've interpreted your question correctly.

Link to comment
https://forums.phpfreaks.com/topic/65310-what-am-i-missing/#findComment-326169
Share on other sites

Thx for the reply, but notice that I have action= and then view=

 

I have attached screenshots so you can see what I got.

 

the first screenshot is the view=add_store_team, in the second screenshot(modified to hide folks names) when the edit icon is clicked it takes you back to the form with their information filled in and gives the action=edit_team_member

 

So I want this if statement to basically read if view not equal to add_store_team OR action not equal to edit_store_team, then show the email form.

 

I hope this clears things up a bit.

 

Thanks,

 

Nate

 

[attachment deleted by admin]

Link to comment
https://forums.phpfreaks.com/topic/65310-what-am-i-missing/#findComment-326181
Share on other sites

assuming you're only ever passing one of the vars, when the $_GET['action'] or $_GET['view'] aren't set, one of the conditions will still ring true.  try this:

 

if ((!isset($_GET['action']) && !isset($_GET['view'])) || (isset($_GET['action']) && $GET['action'] !== 'edit_store_team') || (isset($_GET['view']) && $_GET['view'] !== 'add_store_team'))
{
  // show email row only if neither of the $_GETs are set, or
  // if $_GET['action'] is set and not equal to edit_store_team, or
  // if $_GET['view'] is set and not equal to 'add_store_team'
}

 

my apologies for misreading the code the first time - did i interpret you correctly this time?

Link to comment
https://forums.phpfreaks.com/topic/65310-what-am-i-missing/#findComment-326188
Share on other sites

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.