Jump to content

Recommended Posts

Hello im wondering how i can make a hyperlinks adress be a set after a variable.

this is my php:

 

$result1 = mysql_query("SELECT id, namn, url FROM stuff ORDER BY id desc limit 1;");
$result2 = mysql_query("SELECT id, namn, url FROM stuff ORDER BY id desc limit 1,1;");

<html>
<a href="???"> <p class="note-general"> The first link </p>
<a href="???"> <p class="note-general"> The the second link </p>
</html>

 

The important thing is that the url from $result1 will link under "the first link" and url from $result2 link under "the second link".

Link to comment
https://forums.phpfreaks.com/topic/222575-php-variable-in-hyperlink/
Share on other sites

<a href=<?php $row1 = mysql_fetch_row($result1);echo $row1[2];?> > <p class="note-general"> The first link </p>

<a href=<?php $row2 = mysql_fetch_row($result2);echo $row2[2];?> > <p class="note-general"> The second link </p>

 

I'd do it like this

$result1 = mysql_query("SELECT id, namn, url FROM stuff ORDER BY id desc limit 1;")

$link1 = $result1;

 

$result2 = mysql_query("SELECT id, namn, url FROM stuff ORDER BY id desc limit 1,1;");

$link2 = $result2;

 

<html>

<a href="<echo ''.$link1.'';?>"> <p class="note-general"> The first link </p></a>

<a href="<echo ''.$link2.'';?>"> <p class="note-general"> The the second link </p></a>

</html>

(should the href be inside of the p tag?)

 

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.