I am trying to create a link within a text, I have 2 columns in my table (updates1) and (link1) updates 1 contains a text while link 1 contains a link. The problem is whenever im trying to call it the data or the link itself is being an output besides the text. I need it to be stored inside the text.
echo "<b><h4>{$list["updates1"]}<a>{$list["link1"]}</a></b></h4><hr>";
Try this:
echo '<b><h4>'.$list["updates1"].'</h4></b><hr>';
As per OP's example in the comment:
echo '<b><h4>'.$list["updates1"].'</b></h4><hr>';
Close the <h4> tag before the <b> tag, like this:
echo "<b><h4>{$list["updates1"]}<a>{$list["link1"]}</a></h4></b><hr>";
echo "<b><h4>{$list['updates1']} Your Link Title</h4></b><hr>";
EDIT: Try to close proper way tag
in php you can go through
echo "<b><h4><a href='".$list["link1"]."'>".$list['updates1']."</a></b></h4><hr>";
you can also try it using "\"
echo "<b><h4> {$list['updates1']}</h4></b><hr>";
Related
I have a multi language website. I have three php files:
lang.de.php,lang.en.php, lang.hr.php
On index page I am changing text using this line of code:
<h2><?php echo $lang['TEXT'];?></h2>
Variable TEXT has different value in every lang.php file.
Now, I want to change the name of the .pdf file the same way, but I can't get it to work. I want to do something like this:
How can I do this?
Try to remove the double quotes before and after the
Correct syntax to do this:
I'm noob in php, and i'm trying to concatenate href with words or values ex:
$name = "anonymous";
echo ''.$name.'<br/>';
I want it to look like this when the user clicked the link.
echo ''.$name.'<br/>';
I've tried doing this, but it's not working.
echo ''.$name.'<br/>';
echo ''.$name.'<br/>';
The same way you concatenated the text.
You cant use php tags inside a php tag like this,
echo ''.$name.'<br/>';
It will mess the PHP interpreter so use this
echo "<a href=profile.php/{$name}>".$name."</a><br/>";
I am struggling with an issue which I need a little bit of help with, basically I have created a search bar and when the results come up I only want the 'Session 1' or 'Session 2' to be href'd. Not the whole thing. A photo below:
img http://gyazo.com/eb677171c15b075f1fb4137d28227b3a.png
I would just like the Sessions to be hrefed but the paragraphs just.
My code below:
echo "<p><a href='../pages/session.php</a>".$results['1']."'><h3>".$results['title']."</h3>".$results['text']."</p>";
Linking to my DB
Note that is not all of my code just where I believe the issue lies.
You placed </a> slightly wrong. The correct solution would be like this:
echo "<p><a href='../pages/session.php'>{$results['1']}</a><h3>{$results['title']}</h3>{$results['text']}</p>";
If you use double quotes, you do not need to concatenate variables into your string, they are also validate within the string.
UPDATE
To display only the headlines as links try this:
echo "<a href='../pages/session.php'><h3>{$results['title']}</h3></a><p>{$results['text']}</p>";
You have missed a bracket in ur a tag.It is like <a href='whatever'>blah</a>
Do you just want to href $results['1']? Here you go.
echo "<p><a href='../pages/session.php'>".$results['1']."</a><h3>".$results['title']."</h3>".$results['text']."</p>";
I'm relatively new to this and am familiar with echo in PHP but what I need is to have the contents of a field in a database to be placed in the page (but not as a written field)
For example
<?php echo $product_description['description']; ?>
the field description has html formating in it already so when I use 'echo' it writes out for example
<p>text on firstline <br> text on next line
And what I want is that this html from this field in the database that already has html formating to simply placed in the php page which would make it look like this
text on firstline text on next line
I assume I just need to use a different command than ECHO but don't know which one.
Try
echo html_entity_decode($product_description["description"]);
If that works, the HTML in your database has been encoded using htmlentities, so you must decode it to write to a page.
strip_tags is what you're after.
Use it like so: echo strip_tags($your database bit to echo here);
PHP docs for strip_tags
I found this tutorial that explains what I want to do using html but when I echo out the code with a get variable there is no affect to the page. I would use, for example, the following code:
echo "<a href='post.php?id=".$id."#Comments'>Click here to go to the comments</a>";
echo "<a title='Comments'>Comments</a>";
I presume the problem is to do with the get variable, so would I have to end it, some how, before using the # symbol?
The problem actually lies in your HTML, because the anchor should be parsed correctly by browsers regardless of the query string.
Page anchors use the name attribute instead of the title attribute:
<a name='Comments'>Comments</a>
You can also apply this to the id attribute of any element:
<h2 id='Comments'>Comments</h2>
To define jump-labels you have to set a name and/or id-attribute:
echo "<a title='Comments' name='Comments' id='Comments'>Comments</a>";