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>";
Related
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>";
I am trying to include pagination on a site and I encountered this problem.
I have the following line, but instead of index.php I must put index.php?view_vehicles.
This is the line:
echo "<a href='index.php?page=$next'>Next</a> ";
It's the first time I encounter this issue and I don't know how to make it work.
From comments:
"It must be something like this: <a href='index.php?view_vehicles?page=$next'>Next</a> but it's now working this way. – AndreiCT
As I stated, additional GET parameters require & after the first parameter, not 2x ?.
<a href='index.php?view_vehicles&page=$next'>Next</a>
You should concatenate the variable $next in the string you're echoing:
echo "<a href='index.php?page=".$next."'>Next</>";
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 have a problem I can't solve by myself, don't know how simple it is to solve but I want to open this link in another frame:
<?php echo "<a href=details.php?id=$row[idProdukt]>$row[Produkt_Namn]</a>" ?>
tried to use taget but since it's html I couldn't really wrap my head around how to type it.
any help is greatly appreciated.
Just add the attribute to your anchor tag as usual. Make sure you use the name of the targeted iframe as its value:
<?php echo "<a href='details.php?id=$row[idProdukt]' target='framename'>$row[Produkt_Namn]</a>" ?>
I added quotes around your html attribute values as that is a good practice to be in. It prevents issues arising from errant or intentional spaces in attribute values.
First, you have error on array index, missing quotes. You can use this;
<iframe src="some_url" name="test">
.....
</iframe>
<?php echo "" . $row['Produkt_Namn'] . ""; ?>
The trouble is missing quotes around href attribute value and array key.
echo "{$row['Produkt_Namn']}";
See in action
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>";