mohabitar Posted March 10, 2007 Share Posted March 10, 2007 How do I use echo to print out HTML. I want to be able to use it an a conitional statement and just regular. For example if (mysql_affected_rows() == 1) { //( HOW DO I ECHO HTML HERE))? Thank You. Quote Link to comment https://forums.phpfreaks.com/topic/42127-how-to-echo-html-in-php/ Share on other sites More sharing options...
HoTDaWg Posted March 10, 2007 Share Posted March 10, 2007 <?php if (mysql_affected_rows() == 1) { echo "<b>the row equals 1!</b>"; }else{ echo "The row <b>does not</b> equal 1!"; } ?> although i am unsure of your questions, is that what you were wondering? HoTDaWg Quote Link to comment https://forums.phpfreaks.com/topic/42127-how-to-echo-html-in-php/#findComment-204329 Share on other sites More sharing options...
mohabitar Posted March 10, 2007 Author Share Posted March 10, 2007 Actually I already knew that part, what i was wondering was if for example if (mysql_affected_rows() == 1) { How would i insert like a form for example, or a picture, or video, or anything besides a simple "Thank you for registering with us". Quote Link to comment https://forums.phpfreaks.com/topic/42127-how-to-echo-html-in-php/#findComment-204334 Share on other sites More sharing options...
per1os Posted March 10, 2007 Share Posted March 10, 2007 lol <?php if (mysql_affected_rows() == 1) { print '<form name="frmName" action=page.php><input type="hidden" name="jack" value="1"> <input type="text" name="txtMe" value="" /></form>'; }else{ print '<table><tr><td>Column here</td><td>other column here</td></tr></table>'; } ?> Simple as that my friend, note echo/print are interchangeable. --FrosT Quote Link to comment https://forums.phpfreaks.com/topic/42127-how-to-echo-html-in-php/#findComment-204337 Share on other sites More sharing options...
mfindlay Posted March 10, 2007 Share Posted March 10, 2007 echo '<p>This is some html</p>'; or echo "<p>This is some html with a variable: " . $var . " and some more html</p>"; or echo ("<form name=\"name\"><br /><p>This is some html with an escape character</p>"); hope this helps... Quote Link to comment https://forums.phpfreaks.com/topic/42127-how-to-echo-html-in-php/#findComment-204340 Share on other sites More sharing options...
mohabitar Posted March 10, 2007 Author Share Posted March 10, 2007 Now whats wrong with this? echo '<form action="login.php" method="post"> <fieldset> <p><b>Email Address:</b> <input type="text" name="email" size="20" maxlength="40" value="<?php if (isset($_POST['email'])) echo $_POST['email']; ?>" /></p> <p><b>Password:</b> <input type="password" name="pass" size="20" maxlength="20" /></p> <div align="center"><input type="submit" name="submit" value="Login" /></div> <input type="hidden" name="submitted" value="TRUE" /> </fieldset> </form> </p> '; Because i am getting this error message Parse error: parse error, unexpected T_STRING, expecting ',' or ';' Quote Link to comment https://forums.phpfreaks.com/topic/42127-how-to-echo-html-in-php/#findComment-204356 Share on other sites More sharing options...
per1os Posted March 10, 2007 Share Posted March 10, 2007 the <?=$varname;?> should only be used outside the <?php tags, if you are working inside those tags all you have to do is this: <?php if (isset($_POST['email']) { $emailDisp = $_POST['email'] } echo '<form action="login.php" method="post"> <fieldset> <p><b>Email Address:</b> <input type="text" name="email" size="20" maxlength="40" value="'.$emailDisp.'" /></p> <p><b>Password:</b> <input type="password" name="pass" size="20" maxlength="20" /></p> <div align="center"><input type="submit" name="submit" value="Login" /></div> <input type="hidden" name="submitted" value="TRUE" /> </fieldset> </form> </p> '; ?> --FrosT Quote Link to comment https://forums.phpfreaks.com/topic/42127-how-to-echo-html-in-php/#findComment-204359 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.