asuh Posted May 28, 2008 Share Posted May 28, 2008 Here's the scenario: I have a site that uses some form code in the shopping cart. I have different customers coming through and the forms for each customer are customized. So, when a customer from X uses the shopping cart, he'll see a difference from customer from Y. Here's basically what it looks like: <?php if ( var == "X") { echo "<custom html code>";} elseif ( var == "Y") { echo "<custom html code>";} ?> What I'd like to do, however, is be able for the code to look like it should within the "View Source" of any regular html page. If I include custom code inside an else, there's no way for me to have the proper tab and spacing, is there? If you need more examples, please let me know and I'll try to be even more specific. Link to comment https://forums.phpfreaks.com/topic/107716-formatting-html-within-php-code/ Share on other sites More sharing options...
DarkWater Posted May 28, 2008 Share Posted May 28, 2008 You can use \n and \t to make "proper tabbing and spacing" in the source code of the HTML. Link to comment https://forums.phpfreaks.com/topic/107716-formatting-html-within-php-code/#findComment-552196 Share on other sites More sharing options...
asuh Posted May 28, 2008 Author Share Posted May 28, 2008 So, if I was to use source formatting on a form within the echo statement, how would i format this so that i use proper syntax? For example: <form method='post' action='sony_ok.php'>\n \t<fieldset>\n \t\t<ol>\n \t\t<li>\n \t\t\t\t<input type='hidden' name='mode' value='sonycust'>\n \t\t\t\t<input type='hidden' name='item' value='$item'>\n \t\t\t\t<input type='hidden' name='attnfrst' value='$Sattnfrst'>\n \t\t\t\t<input type='hidden' name='attnlast' value='$Sattnlast'>\n I'd like to be able to properly use double quotes in the <form> and <input> field. Is there not a better, easier way to do this? Link to comment https://forums.phpfreaks.com/topic/107716-formatting-html-within-php-code/#findComment-552204 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.