xtiancjs Posted April 2, 2006 Share Posted April 2, 2006 Hi all, I am trying to write a hopefully simple if else statement that would be something like this psuedo codeif $variable = o display <form>form content</form>else echo"some message to the user"not quite sure how I would write that. xtian Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted April 2, 2006 Share Posted April 2, 2006 Have you tried anything yet?Something like this should work:[code]<?phpif ($variable == 'o') { ?><form ...></form><?php } else echo "some message to the user<br>\n";?>[/code]Ken Quote Link to comment Share on other sites More sharing options...
xtiancjs Posted April 2, 2006 Author Share Posted April 2, 2006 [!--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]<?phpif ($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 outxtian Quote Link to comment Share on other sites More sharing options...
xtiancjs Posted April 2, 2006 Author Share Posted April 2, 2006 [!--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 outxtian[/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();"> <?phpdo { ?> <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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.