wkilc Posted December 1, 2010 Share Posted December 1, 2010 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 https://forums.phpfreaks.com/topic/220298-simple-else-statement/ Share on other sites More sharing options...
trq Posted December 1, 2010 Share Posted December 1, 2010 The comparison operator is == not = if ($Address_type == 'school') Also, why all the calls to stripslashes()? If there is slashes in your data you are not escaping it properly on the way into the database. Link to comment https://forums.phpfreaks.com/topic/220298-simple-else-statement/#findComment-1141591 Share on other sites More sharing options...
Pikachu2000 Posted December 1, 2010 Share Posted December 1, 2010 So what seems to be the problem? Is it not working? Also, is there a reason you're using stripslashes() to display data retrieved from a database? It shouldn't be necessary unless the data isn't being inserted properly. Link to comment https://forums.phpfreaks.com/topic/220298-simple-else-statement/#findComment-1141592 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.