Jump to content

if else to display form


xtiancjs

Recommended Posts

Hi all, I am trying to write a hopefully simple if else statement that would be something like this psuedo code

if $variable = o display <form>form content</form>
else echo"some message to the user"

not quite sure how I would write that.

xtian
Link to comment
Share on other sites

[!--quoteo(post=360766:date=Apr 1 2006, 08:06 PM:name=kenrbnsn)--][div class=\'quotetop\']QUOTE(kenrbnsn @ Apr 1 2006, 08:06 PM) [snapback]360766[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Have you tried anything yet?

Something like this should work:

[code]<?php
if ($variable == 'o') { ?>
<form ...>

</form>
<?php } else echo "some message to the user<br>\n";
?>[/code]

Ken
[/quote]

Thanks for the quick reply, I have attempted a few things , I had enclosed everything in only one <?php ?>, and was having trouble with my form,thanks again ,will try it out
xtian
Link to comment
Share on other sites

[!--quoteo(post=360768:date=Apr 1 2006, 08:13 PM:name=xtiancjs)--][div class=\'quotetop\']QUOTE(xtiancjs @ Apr 1 2006, 08:13 PM) [snapback]360768[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Thanks for the quick reply, I have attempted a few things , I had enclosed everything in only one <?php ?>, and was having trouble with my form,thanks again ,will try it out
xtian
[/quote]

Hi , just intergrated your suggestion Ken, it worked like a charm, out of general interest here is the final code I used
[code]<td><?php $vipone = $_SERVER['REMOTE_ADDR'];
               $viponeq = mysql_query("SELECT ip FROM voter_ip WHERE ip = '$vipone'");
               if ($viponeq == '0') { ?>
            <form method="post" name="form1" action="<?php echo $editFormAction; ?>">
                <table align="center">
                  <tr valign="baseline">
                    <td nowrap align="right"><select name="broker_rating" onClick="DoSubmission1();">
                        <?php
do {  
?>
                        <option value="<?php echo $row_valueset['value']?>"<?php if (!(strcmp($row_valueset['value'], $row_bprofile['broker_rating']))) {echo "selected=\"selected\"";} ?>><?php echo $row_valueset['value']?></option>
                        <?php
} while ($row_valueset = mysql_fetch_assoc($valueset));
  $rows = mysql_num_rows($valueset);
  if($rows > 0) {
      mysql_data_seek($valueset, 0);
      $row_valueset = mysql_fetch_assoc($valueset);
  }
?>
                      </select></td>
                    <td></td>
                  <tr>
                </table>
                <input type="hidden" name="id" value="<?php echo $row_bprofile['id']; ?>">
                <input type="hidden" name="broker_num_votes" value="<?php echo $row_bprofile['broker_num_votes']; ?>">
                <input type="hidden" name="MM_update" value="form1">
                <input type="hidden" name="id" value="<?php echo $row_bprofile['id']; ?>">
                <input type="hidden" name="ip" value="<?php echo($_SERVER['REMOTE_ADDR']); ?>">
                <input type="hidden" name="page" value="<?php echo($_SERVER['REQUEST_URI']); ?>">
                <input type="hidden" name="MM_insert" value="form1">
              </form><?php } else echo "You have already voted!<br>\n"; ?></td>[/code]

thanks again
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.