473,403 Members | 2,366 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Is it possible to make a field into a link?

w33nie
56
I want to get my database working in a way that when the user is viewing my web site, clicking a certain field on my php/mySQL data, will take them to another web page.

Is this possible?


and please excuse my probably poor choice of mySQL related words.
Mar 30 '07 #1
6 5884
code green
1,726 Expert 1GB
Yes. But are you asking a database question, a php or HTML question? If its all three then we need your DB table structure and the code developed so far
Mar 30 '07 #2
w33nie
56
well i have no idea what area i'd be asking it in, but i assumed there might be a way to make a link directly from the mySQL database.
here's my stuff anyway:

[PHP]<? $hostname = "p*smysql*.secureserver.net"; // The mySQL DB server.
$username = "******"; // The username you created for this database.
$password = "******"; // The password you created for the username.
$usertable = "round1"; // The name of the table you made.
$dbName = "acssl_fixtures"; // This is the name of the database you made.

MYSQL_CONNECT($hostname, $username, $password) OR DIE("DB connection unavailable");
@mysql_select_db( "$dbName") or die( "Unable to select database");
?>
<?
//error message (not found message)begins
$XX = "Table error. Refresh this page or contact the site administrator.";
//query details table begins
$query = mysql_query("SELECT * FROM `round1` LIMIT 0, 30 ");
while ($row = @mysql_fetch_array($query))
{
$variable1=$row["#"];
$variable2=$row["home"];
$variable3=$row["score"];
$variable4=$row["away"];
$variable5=$row["time"];
$variable6=$row["date"];
//table layout for results

print ("<tr>");
print ("<td width='180'><span class='Body'>$variable2</span></td>");
print ("<td width='90' align='center'><span class='Body'>$variable3</span></td>");
print ("<td width='180'><span class='Body'>$variable4</span></td>");
print ("<td width='100'><span class='Body'>$variable5</span></td>");
print ("<td><span class='Body'>$variable6</span></td>");
print ("</tr>");
}
//below this is the function for no record!!
if (!$variable1)
{
print ("$XX");
}
//end
?>[/PHP]
this is a database that keeps the records and times of matches.
I want to convert the variable3, into a link.
but only have the link working in certain cases.
Mar 30 '07 #3
w33nie
56
as in, in some cases, variable3 will be "v", but in other cases it will be a range of numbers.

i then want to specify a web page, that the user would be taken to upon clicking one of the variable3's.
but i want it to go to a different web page for different lines of variable3.
Mar 30 '07 #4
code green
1,726 Expert 1GB
Just a tip first. Use single quotes ' ' instead of double " ". They parse much faster.
but i want it to go to a different web page for different lines of variable3
Ideally your DB needs another field with the link page. The data could be written into this field in HTML format as a hyperlink or just the filename (recommended). Then when you read the data from the recordset there will be an extra variable [PHP]$link=$row['link']; # contains the linking page filename[/PHP]If 'link' is the filename rather than HTML create the hyperlink at this point.
[PHP]$link = '<a href="'.$row["link"]. ' "> '.$row['score']. '</a>';[/PHP]maybe what you are looking for. I have spaced out the quotes and periods for clarity but remove the spaces in your code
Mar 30 '07 #5
w33nie
56
Just a tip first. Use single quotes ' ' instead of double " ". They parse much faster.Ideally your DB needs another field with the link page. The data could be written into this field in HTML format as a hyperlink or just the filename (recommended). Then when you read the data from the recordset there will be an extra variable [PHP]$link=$row['link']; # contains the linking page filename[/PHP]If 'link' is the filename rather than HTML create the hyperlink at this point.
[PHP]$link = '<a href="'.$row["link"]. ' "> '.$row['score']. '</a>';[/PHP]maybe what you are looking for. I have spaced out the quotes and periods for clarity but remove the spaces in your code
thanks, that works just fine.
but, i can't get rid of the underline under my fields when i view the web site now.
I've got the proper css file set up, everything in it works except for the underline.
any suggestions?
Mar 30 '07 #6
code green
1,726 Expert 1GB
[HTML]text-decoration:none[/HTML]
Apr 2 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Acorn Tutors | last post by:
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...
5
by: Pugi! | last post by:
Hi, I would like to upload office-document (doc, xls, ...) using a form to a website (apache, php, mysql) in a specific directory and if possible insert it into a table (MySQL-db). Is this...
12
by: Jeff Lanfield | last post by:
First of all, I apologize if coalescing is not the right term to describe my problem. I have a tree where each node has the same set of attributes (is the same entity) but child nodes should...
39
by: Mark Johnson | last post by:
It doesn't seem possible. But would the following also seem a violation of the general notions behind css? You have a DIV, say asociated with class, 'topdiv'. Inside of that you have an anchor...
17
by: Michael Fan | last post by:
I am a newbie for web servcie and want to write a web service which monitors the certain field in the database. Once it exceeds the certain value, web service will send out notification to web...
6
by: M. Schroeder | last post by:
I use an Access-form to write into an external Oracle table via Oracle-ODBC driver. It is not a read-only connection, and batch autocommit mode set to "all successful statements". I can read...
3
by: mvivar | last post by:
Dear guys: First of all, I have to thank all of you, because I have found lots of answers since months without having to call your attention to me until now. I have a database in access 97...
2
by: Nick Gilbert | last post by:
Hi I have a number of pages where it is valid for the user to enter HTML. On these pages, I have turned off RequestValidation ("ValidateRequest = false" in the page directive) so that the...
9
by: Wayne Smith | last post by:
I've come up against a major headache that I can't seem to find a solution for but I'm sure there must be a workaround and I would really be grateful of any help. I'm currently building a web...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.