Page 1 of 1

data retrieved from db with links

Posted: Sat Apr 19, 2008 3:10 pm
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?

Re: data retrieved from db with links

Posted: Sun Apr 20, 2008 6:38 am
by aceconcepts
Can you give an example of what you mean?

Re: data retrieved from db with links

Posted: Sun Apr 20, 2008 10:51 am
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)

Re: data retrieved from db with links

Posted: Sun Apr 20, 2008 10:54 am
by John Cartwright
Please don't hijack someone else's thread.

Topic split from viewtopic.php?f=1&t=81623

Re: data retrieved from db with links

Posted: Sun Apr 20, 2008 11:19 am
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>';