data retrieved from db with links

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
fantastapotamus
Forum Newbie
Posts: 3
Joined: Sat Apr 19, 2008 1:28 pm

data retrieved from db with links

Post by fantastapotamus »

Hi,

I've a similar PHP issue and was wondering if you could help me as well.

I'm trying to do similar as above - basically a bunch of tags that the user has submitted - when the user clicks on a tag, it opens a new page that shows all other items that have that same tag.

I can retrieve the tags for an item on the page, but can't display them as html links. I'm also unsure as to how, when I've made the links, that it'll open up the page with the items that have these tags.

I think its similar to the above, but could you help?
User avatar
aceconcepts
DevNet Resident
Posts: 1424
Joined: Mon Feb 06, 2006 11:26 am
Location: London

Re: data retrieved from db with links

Post by aceconcepts »

Can you give an example of what you mean?
fantastapotamus
Forum Newbie
Posts: 3
Joined: Sat Apr 19, 2008 1:28 pm

Re: data retrieved from db with links

Post by fantastapotamus »

Sure thing.

It's a (mock) e-commerce site, with tagging so users can tag items with keywords (e.g. Action, etc). I've created a DB that users can enter tags into and I can display the tags as text. What I'm wanting to do is display the tags as HTML links, so the user clicks a tag and this opens up a new page - which shows others items with that tag.

I'm having a problem just displaying the tags as HTML links!

I've been told that it needs to pass the tag_id as a variable into this new php page, but I'm a bit confused as to how I can do that.

Code: Select all

 
$result = mysql_query($query, $connect)
or die(mysql_error());
 
while ($nt=mysql_fetch_array($result))
{
echo '<a href="tags.php?id=" .$nt["id"]"></a>';
}
 
This is the code that I've been playing with - in the DB there is a tag table which has NAME (name a user has inputted and tagged) TAG_ID (auto increment, PK) and url (url = the item that the user has tagged)
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: data retrieved from db with links

Post by John Cartwright »

Please don't hijack someone else's thread.

Topic split from viewtopic.php?f=1&t=81623
User avatar
aceconcepts
DevNet Resident
Posts: 1424
Joined: Mon Feb 06, 2006 11:26 am
Location: London

Re: data retrieved from db with links

Post by aceconcepts »

re-write the following:

Code: Select all

 
echo '<a href="tags.php?id=" .$nt["id"]"></a>';
 
with

Code: Select all

 
echo '<a href="tags.php?id=' . $nt["id"] .' "></a>';
 
Post Reply