Jump to content

Formating PHP | NUB question


tarleton

Recommended Posts

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.

 

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.