Jump to content

simple "else" statement


wkilc

Recommended Posts

Hello,

 

I'm pulling data from a table in order to pre-populate a form.  I have either a "school" address or a "home "addresses" for each record in the table.  I've already connected to the table and made the query... what I need to do now is simply create an "else" statement.  If the value "Address_type" is "school", pre-populate the form... if it's not "school" then display an empty form:

 

I think I've got the idea, but my syntax can't be right:

 

<?php 
if ($Address_type = 'school') 
{ 
?>

School address street</b>:
<input type="text" name="Address_street" value="<?php echo stripslashes($row['school_address']); ?>" />

School address city</b>:
<input type="text" name="Address_city" value="<?php echo stripslashes($row['school_city']); ?>" />

School address state</b>:
<input type="text" name="Address_state" value="<?php echo stripslashes($row['school_state']); ?>" />

School address zipcode</b>:
<input type="text" name="Address_zip" value="<?php echo stripslashes($row['school_zip']); ?>" />

<?php
}else {
?>

School address street</b>:
<input type="text" name="Address_street" />

School address city</b>:
<input type="text" name="Address_city" />

School address state</b>:
<input type="text" name="Address_state" />

School address zipcode</b>:
<input type="text" name="Address_zip" />

<?php
}
?>

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.