Jump to content

\n within variable


mrt003003

Recommended Posts

Hi there im trying to add a "\n" to some text and select results but its not creating a new line and is just presented across the screen, i want the data in rows.

 

 

Like this:

Credit Output: 50

Construction Yard Level: 1

 

Not like this:

Credit Output: 50 Construction Yard Level: 1

 

 

$alderaancredits = "Credit Output: ";
$alderaancyard = "Construction Yard Level:";

$alderaanalt = $alderaancredits."" .$row_Alderaan['Credits']." \n".$alderaancyard." ".$row_Alderaan['CYardLevel1'];

 

The variable $alderaanalt is being used as alt in a hyperlink.

 

Can you help please???

 

Thank you :)

Link to comment
Share on other sites

Yes exactly...

 

The break is added after the data of the Credits so:

 

$alderaanalt = $alderaancredits."" .$row_Alderaan['Credits']." </br>".$alderaancyard." ".$row_Alderaan['CYardLevel1'];

 

Credits  50

Construction Yard 1

 

but instead it just outputs the </br>

 

 

Credits  50 </br> Construction Yard 1

 

Thanks

Link to comment
Share on other sites

So, if you did this

$alderaanalt = $alderaancredits."" .$row_Alderaan['Credits']."<br/>\n".$alderaancyard." ".$row_Alderaan['CYardLevel1'];

Your resulting output will be displaying <br/> tags on the page?

 

Are you using htmlentities on the string before you output it?

Link to comment
Share on other sites

Heres where i assign text to two variables:

$alderaancredits = "Credit Output: ";
$alderaancyard = "Construction Yard Level:";

 

Then I assign my 3rd variable with the text from the other variables and the data from my database:

$alderaanalt = $alderaancredits."" .$row_Alderaan['Credits']." <br/>".$alderaancyard." ".$row_Alderaan['CYardLevel1'];

 

And finally i had the variable with all the text and data from the database to the alt or title of my hyperlink:

 

echo '<a href="http://localhost/swb/planet.php?recordID='.$row_Planet['PlanetID'].'" title ="' .$alderaanalt. '">

 

This is then outputted as: Credits  50 <br/> Construction Yard 1

 

I want it to look like:

 

Credits  50

Construction Yard 1

 

Thanks :)

 

 

Link to comment
Share on other sites

Riiiiight.. You are trying to add a line break into a title tag..

That kind of information would have helped from the start :)

Try this

$alderaanalt = $alderaancredits . $row_Alderaan['Credits'] . '\n' . $alderaancyard . ' ' . $row_Alderaan['CYardLevel1'];

 

Edit: Ignore that (that is how you do it in JavaScript).. Line breaks in title tags is only supported in some browsers.. Try using JavaScript tooltips or something..

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.