472,982 Members | 2,242 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,982 software developers and data experts.

How do you take a db table entry and make it into a link?

Hi folks, what I would like to do is to store the name of a link, such as
link1.php in a field, lets say the field is called Favoritelinks, in a
database as a bit of text. Then, on a logged in page, pull the value from
the field and put in right in the <a href><a> tag so that the link now
points to a file, and is dynamic. And, depending on the username and
password, the value taken from Favoritelinks changes.

What Im after is to provide a link from a field (in this case
Favoritelinks). The entry in the field is simple text such as "link1.php".
Then, in a logged in file, use this text to create a link. Now, as to which
row is accessed to provide the actual text from the Favoritelinks field,
that depends on matching a username and password from two other fields in
the same table.

So, for example username bill, password test1 will have the entry link1.php
in his Favoritelinks field. username frank, password test2 will have the
entry link2.php in his Favoritelinks field. I would like to have the logged
in screen change so that the hypertext link will point to link1.php in the
link for bill if he logs in and for it to then be link2.php if frank logs
in.

So if bill logs in the html will show <a href: link1.php>Click here<a>

and if frank logs in, it will show <a href: link2.php>Click here<a>

Jul 17 '05 #1
2 2110
Acorn Tutors wrote:
So if bill logs in the html will show <a href: link1.php>Click here<a>

and if frank logs in, it will show <a href: link2.php>Click here<a>


Your HTML is wrong: it should be

<a href="link1.php">Click here</a>
_______^_______________________^__
After you get the text from the database simply echo it!

<a href="<?php echo $dbdata['FavouriteLink']; ?>">Click here</a>
--
I have a spam filter working.
To mail me include "urkxvq" (with or without the quotes)
in the subject line, or your mail will be ruthlessly discarded.
Jul 17 '05 #2
"Acorn Tutors" <in**@acorntutors.com> wrote in message
news:<Tt*******************@news20.bellglobal.com> ...

what I would like to do is to store the name of a link, such as
link1.php in a field, lets say the field is called Favoritelinks,
in a database as a bit of text. Then, on a logged in page, pull
the value from the field and put in right in the <a href><a> tag
so that the link now points to a file, and is dynamic. And,
depending on the username and password, the value taken from
Favoritelinks changes.


OK, let's say your users store their favorite links in a table
called `links`, which has a bunch of fields including these:

user_id (the ID of the user to whom the link belongs)
URL (the URL to the resource)
description (the description of the resource)

So here is what you need to do to display links that belong to the
user whose ID is, say, 123:

mysql_connect ('host', 'user', 'password')
or die ('Could not connect: ' . mysql_error ());
mysql_select_db ('mydb')
or die ('Could not select database');
$query = 'SELECT URL, description FROM links WHERE user_id=123';
$result = mysql_query ($query)
or die ('Query failed: ' . mysql_error ());
echo "<ul>\n";
while ($link = mysql_fetch_array($result, MYSQL_ASSOC)) {
echo '<li><a href="', $link['URL'],
'">', $link['description'], "</a>\n";
}
echo "</ul>\n";

Cheers,
NC
Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: ajay | last post by:
I have following code for a slide menu but i twiked it to work for a single level menu. Open it in a Browser to get a clear picture. I have 2 Qs 1) How to make first entry as non-link. i.e i...
35
by: .:mmac:. | last post by:
I have a bunch of files (Playlist files for media player) and I am trying to create an automatically generated web page that includes the last 20 or 30 of these files. The files are created every...
5
by: john_williams_800 | last post by:
Hi; I am just starting to use the DOM to do some more advanced javascripting so please be patient with my question if it is an ignorant question. I would like to use the DOM to dynamically...
1
by: Mats Kling | last post by:
Hi all, We are logging approx. 3 million records every day into a history table. Last week we ran into the 64 GB limit in UDB 8 so we recreated the table with 8 k pagesize to get some...
0
by: elvin | last post by:
Okay - apologize in advance for the length, but I want to make sure all you knowledgeable and helpful people have all the details you need to hopefully point my newbie rear in the right direction....
4
by: m_houllier | last post by:
STUDENT TABLE StudentReference Student Name etc ATTENDANCE TABLE AttendanceID CourseID StudentReference
21
by: Johan Tibell | last post by:
I would be grateful if someone had a minute or two to review my hash table implementation. It's not yet commented but hopefully it's short and idiomatic enough to be readable. Some of the code...
4
by: Deus402 | last post by:
Here is my table design: tblEmployers EmployerID autonum (primary key) EmployerName text tblLocations LocationID autonum (primary key) EmployerID longint (foreign key) LocationAdress text
0
by: elainenguyen | last post by:
I am writting an address book which store name and address. I've written a Node class with Get and Set method of String key and String value I've also written a Main class for the menu to promt...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.