tarleton Posted October 2, 2009 Share Posted October 2, 2009 Hi all real nub questions so sorry. <?php error_reporting(E_ALL); require("C:/xampp/htdocs/game/forums/SSI.php"); $array = ssi_recentTopics( 3, null, 'array'); foreach ($array as $post) { echo '<li>'; echo '<a href="', $post['href'], '">', $post['subject'], '</a>'; echo '</li>'; } ?> I want to make <a href="', $post['href'], '"> <strong> and $post['subject'] <em> however i get errors whenever i add the tags around them. Quote Link to comment https://forums.phpfreaks.com/topic/176299-formating-php-nub-question/ Share on other sites More sharing options...
mikesta707 Posted October 2, 2009 Share Posted October 2, 2009 echo '<strong><a href="'. $post['href']. '"><em>'. $post['subject']. '</em></a></strong>'; you were concatenating incorrectly. You use periods ('.') not commas to concatenate Quote Link to comment https://forums.phpfreaks.com/topic/176299-formating-php-nub-question/#findComment-929167 Share on other sites More sharing options...
cags Posted October 2, 2009 Share Posted October 2, 2009 Actually not wishing to confuse the OP, but... echo '<a href="', $post['href'], '">', $post['subject'], '</a>'; ...is a perfectly valid way of outputing data. Some argue it's actually better than.... echo '<a href="' . $post['href'] . '">' . $post['subject'] . '</a>'; It is not concatinating the strings together, it is using echo's ability to accept multiple parameters to output the data. As to tarleton, what error are you getting? Quote Link to comment https://forums.phpfreaks.com/topic/176299-formating-php-nub-question/#findComment-929172 Share on other sites More sharing options...
tarleton Posted October 2, 2009 Author Share Posted October 2, 2009 Thanks for ur help guys, Mikes thing didn't work kinda screwed up the display of everything. This is what i've tried echo '<strong><a href="', $post['href'], '</strong>">', <em>$post['subject'], '</a></em>'; Get this error Parse error: parse error in C:\xampp\htdocs\game\manager\includes\document.parser.class.inc.php(770) : eval()'d code on line 9 Quote Link to comment https://forums.phpfreaks.com/topic/176299-formating-php-nub-question/#findComment-929173 Share on other sites More sharing options...
cags Posted October 2, 2009 Share Posted October 2, 2009 Try this... echo '<strong><a href="', $post['href'], '</strong>">', '<em>', $post['subject'], '</a></em>'; Your open <em> tag was not in speach marks to signify it as a string, it was also not concatenated with the . or seperated with a comma. Quote Link to comment https://forums.phpfreaks.com/topic/176299-formating-php-nub-question/#findComment-929174 Share on other sites More sharing options...
mikesta707 Posted October 2, 2009 Share Posted October 2, 2009 Oh my bad, learn something new every day i suppose. I thought only python did that. thats pretty cool echo '<strong><a href="', $post['href'], '"</strong>>', '<em>'.$post['subject'], '</a></em>'; you can do that, but that doesn't really make much sense, and isn't remotely close to valid XHTML it would basically look like <strong><a href="somevalue"</strong>><em>somevalue</a></em> you cant have other tags inside some tags. you close tags out of order, and it seems that you are trying to bold the first part of the <a> tag. I'm not sure why you are doing that, but even if that was valid, it wouldn't do anything. What exactly are you trying to get the output to look like? Quote Link to comment https://forums.phpfreaks.com/topic/176299-formating-php-nub-question/#findComment-929177 Share on other sites More sharing options...
cags Posted October 2, 2009 Share Posted October 2, 2009 Ooops, I didn't even check the validity of the HTML, I just saw the PHP was wrong and fixed it. Quote Link to comment https://forums.phpfreaks.com/topic/176299-formating-php-nub-question/#findComment-929180 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.