co.ador Posted January 11, 2010 Share Posted January 11, 2010 <?php <label>Tel:</label> <div>' . $row['tel'] . '</div> <label>Address:</label> <div>'. $row['address'] . '</div> <div>' $row['county'] . . $row['state'] . '</div> <div>'. ['zip'] . '</div> ?> I have a parse error in this line <?php <div>' $row['county'] . $row['state'] . '</div>?> Help! Quote Link to comment https://forums.phpfreaks.com/topic/188086-appending-several-indexes-help/ Share on other sites More sharing options...
wildteen88 Posted January 11, 2010 Share Posted January 11, 2010 You cant place HTML code within PHP tags. You need to use echo or print. <?php echo '<label>Tel:</label> <div>' . $row['tel'] . '</div> <label>Address:</label> <div>'. $row['address'] . '</div> <div>'. $row['county'] . $row['state'] . '</div> <div>'. ['zip'] . '</div>'; ?> Quote Link to comment https://forums.phpfreaks.com/topic/188086-appending-several-indexes-help/#findComment-992985 Share on other sites More sharing options...
co.ador Posted January 11, 2010 Author Share Posted January 11, 2010 So, what would be the reason or reasons for avoiding the use of html inside php code? Newbie Thank you. Quote Link to comment https://forums.phpfreaks.com/topic/188086-appending-several-indexes-help/#findComment-992989 Share on other sites More sharing options...
wildteen88 Posted January 11, 2010 Share Posted January 11, 2010 PHP does not understand HTML, therefore you can't place raw HTML within the php tags. You need to use echo (or print) to send the html to the browser, as I showed you in my previous post: <?php echo '<label>Tel:</label> <div>' . $row['tel'] . '</div> <label>Address:</label> <div>'. $row['address'] . '</div> <div>'. $row['county'] . $row['state'] . '</div> <div>'. ['zip'] . '</div>'; ?> Quote Link to comment https://forums.phpfreaks.com/topic/188086-appending-several-indexes-help/#findComment-992996 Share on other sites More sharing options...
co.ador Posted January 11, 2010 Author Share Posted January 11, 2010 I have taken out the html and done it like this now. <?php Tel:' . $row['tel'] . ' <br/> Address:'. $row['address'] . '<br/> '. $row['county'] . $row['state'] . '<br/> '. $row['zip'] . '<br/> ?> That appending works but how can I put a commar in between county and state? Something else I want to know how can I put an space so that county, state and zip display below the address? like. Tel: 978-450-2321 Address: 2334 sedwick ave. Worcester, ma 01561 how can I reach a display just like the above withou html tags? thank you. Quote Link to comment https://forums.phpfreaks.com/topic/188086-appending-several-indexes-help/#findComment-992998 Share on other sites More sharing options...
co.ador Posted January 11, 2010 Author Share Posted January 11, 2010 I understand now, I done a mistake in the first post and I have not put any echo in it. Thank you. Quote Link to comment https://forums.phpfreaks.com/topic/188086-appending-several-indexes-help/#findComment-992999 Share on other sites More sharing options...
co.ador Posted January 11, 2010 Author Share Posted January 11, 2010 Anyways How can I put a comma in the code in your post? in between county and state I guess after the dotto put a but not sure ', ' thanks Quote Link to comment https://forums.phpfreaks.com/topic/188086-appending-several-indexes-help/#findComment-993006 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.