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?
data retrieved from db with links
Moderator: General Moderators
-
fantastapotamus
- Forum Newbie
- Posts: 3
- Joined: Sat Apr 19, 2008 1:28 pm
- aceconcepts
- DevNet Resident
- Posts: 1424
- Joined: Mon Feb 06, 2006 11:26 am
- Location: London
Re: data retrieved from db with links
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
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.
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)
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>';
}
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
- aceconcepts
- DevNet Resident
- Posts: 1424
- Joined: Mon Feb 06, 2006 11:26 am
- Location: London
Re: data retrieved from db with links
re-write the following:
with
Code: Select all
echo '<a href="tags.php?id=" .$nt["id"]"></a>';
Code: Select all
echo '<a href="tags.php?id=' . $nt["id"] .' "></a>';