Jump to content

if else to display form


xtiancjs

Recommended Posts

[!--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
https://forums.phpfreaks.com/topic/6368-if-else-to-display-form/#findComment-23036
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
https://forums.phpfreaks.com/topic/6368-if-else-to-display-form/#findComment-23042
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.