Jump to content

if else and includes...maybe


libinaz

Recommended Posts

The following code will be placed on a users page. If they are the contact then they will be able to remove inactive members. If they are not the contact, then they get a link to the contact person in the event they want to be removed. The first part works...sort of.

I need the first section to 'show' only if they are the institution contact, else then it shows who the contact is.

1. Do I need to echo each and every line?
ie. echo '<form name="form1" method="post" action="removeinactive.php">';

2. What happens when I get where the other queries are? Should I just place all of the queries at the top of the page?

3. Is there another way to do this, like if you are the contact, echo '<?php display_contact_form() ?>'; } else { echo '<?php display_contact_person() ?>'; and use an include?

any help is appreciated. this is driving me nuts.

[code]
<?php
$query_contact = "SELECT * FROM users_tbl WHERE institutioncontact = 'Yes'
AND institutionname = '$institutionname'";
$institutioncontact = mysql_query($query_contact)
or die("Problem with the query: $query_contact<br>" . mysql_error());
$row = mysql_fetch_assoc($institutioncontact);
if (isset($row['institutioncontact']) && $row['institutioncontact']=="Yes") { ?>
              <form name="form1" method="post" action="removeinactive.php">
                <table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#CCCCCC">
                  <tr>
                    <td bgcolor="#CCCCCC"><table width="100%" border="0" align="left"
cellpadding="4" cellspacing="0" class="bodytext">
                        <tr class="bodytextbold">
                          <td colspan="4" class="header"><?php $query_billemaile =
"SELECT * FROM users_tbl WHERE institutionname = '$institutionname' AND
expired < 4 ORDER BY bill_email ASC";
$billEmaile = mysql_query($query_billemaile) or die(mysql_error());
$row_member5 = mysql_fetch_assoc($billEmaile);
$totalRows_billEmaile = mysql_num_rows($billEmaile); ?>
                              <?php echo $institutionname; ?>'s Active Members<br>
                              <span class="bodytext">You can remove ineligible
                              members from the Active Members list here. To remove
                              them, select the checkbox to the left and select
                              the 'Remove' button.</span>
                              <p><span class="bodytext"> If you accidently removed
                                  a membership, or need assistance, <a href="../contact.html">contact
                                  NAACO</a>.</span></p>
                          </td>
                        </tr>
                        <tr>
                          <td width="5%"></td>
                          <td width="36%"><strong>Email Address</strong></td>
                          <td width="59%"><strong>Member Name</strong></td>
                        </tr>
                        <?php do { ?>
                        <tr>
                          <td><input type="radio" name="bill_email" value="<?php echo $row_member5['bill_email']; ?>">
                          </td>
                          <td><?php echo $row_member5['bill_email']; ?></td>
                          <td><?php echo $row_member5['lname']; ?>,
<?php echo $row_member5['fname']; ?></td>
                        </tr>
                        <?php } while ($row_member5 = mysql_fetch_assoc($billEmaile)); ?>
                      </table>
                    </td>
                  </tr>
                  <tr>
                    <td bgcolor="#CCCCCC"><input type="submit" name="Submit" value="Remove">
                    </td>
                  </tr>
                  <tr>
                    <td>&nbsp;</td>
                  </tr>
                </table>
              </form>
              <table width="100%" border="0" cellspacing="0" cellpadding="5">
                <tr>
                  <td bgcolor="#CCCCCC"><form name="form2"
method="post" action="inactivemembers.php">
                      <input name="institutionname2" type="hidden"
value="<?php echo $institutionname; ?>">
                      <span class="bodytext">Select to</span>
                      <input type="submit" name="Submit" value="Review all Deactivated Members">
                    </form>
                  </td>
                </tr>
              </table> <?php
  }
else
{
echo 'Your institution contact is ' . $row['lname']; echo', ' . $row['fname'];
echo '<a href="mailto:'.$row['bill_email'].'"> Email Your Contact</a>';
}
?>[/code]
Link to comment
Share on other sites

I am trying to get this to work using the functions. My page loads fine, but the display isn't showing up.

In my form I have the require_once('mydisplays.php'); and
[code]
<?php
$query_contact = "SELECT * FROM users_tbl WHERE bill_email = '$billEmail'";
$institutioncontact = mysql_query($query_contact) or die("Problem with the query: $query_contact<br>" . mysql_error());
$row2 = mysql_fetch_assoc($institutioncontact);
if (isset($row2['institutioncontact']) && $row2['institutioncontact']=="Yes") {
echo '<?php display_contact_form() ?>';
}
else
{
echo '<?php display_contact_person() ?>';
}

?>[/code]

and mydisplays.php
[code]
<?php
function display_contact_form()
{
?>
contact information
<?php
};

function display_contact_person()
{
?>
contact person
<?php
};
?>[/code]
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.