Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hyperlink problem 2

Status
Not open for further replies.

Deef666

Programmer
May 15, 2005
9
BE
Hi,

I have 2 problems.

1. How do I make a php code go to an other webpage
2. I have made a css file and I've included a profile for hyperlinks. When I make a hyperlink in HTML I get that profile. When I make a link in PHP it doesn't work.

Greetz
 
1) use the header() function
2) Sample code that works? Sample code that doesn't work?

Ken
 
Ok, tnx I wil use the header function.

For the second problem I load the css through this link.

<link href="Site.css" rel="stylesheet" type="text/css">

When I create a hyperlink with html-language

It looks like this

<a href="Test.htm">Test</a>

In Php it looks like this:

echo "<a href=\"" . $data['Link'] . "\">" . $data['Omschrijving'] . "</a><br>";

when made with html it takes my css with php it doesn't. I just don't get it :)
 
Looking at the minimal amount of code you posted, I can't see a problem.

If you do a show source after accessing the PHP script, does it look right?

I would change the echo statment to:
Code:
echo '<a href="' . $data['Link'] . '">' . $data['Omschrijving'] . "</a><br>\n";

It's just my preference. It doesn't change what happens. I just think it's cleaner.

Ken
 
THis is the code when it's generated I adapted what you told me. One question. Why do you use "\n"?

Code:
<html>
<head>
	<title>DC leerplatform</title>
	<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
	<link href="Site.css" rel="stylesheet" type="text/css">
</head>

<body>

<table class="Header" width="100%" cellspacing="0" cellpadding="0">
	<tr>
		
    <td> <h1 align="center"><img src="Afbeeldingen/AanmeldTitel.gif" width="402" height="83"></h1>
		</td>
	</tr>
</table>
<br>
<table width="100%" border="0" cellspacing="2" cellpadding="0">
  <tr>
    <th><table class="navi" width="100%" border="1" cellspacing="0" cellpadding="0">
        <tr>
          <td width="15%" bgcolor="#D7D7D7">
		  	Cursus<br>
		  	<hr>
			<a href="Index.php?Link=Word.php">Word</a><br><a href="Index.php?Link=Excel.php">Excel</a><br><a href="Index.php?Link=Access.php">Access</a>

this is my php page

Code:
<html>
<head>
	<title>DC leerplatform</title>
	<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
	<link href="Site.css" rel="stylesheet" type="text/css">
</head>

<body>

<table class="Header" width="100%" cellspacing="0" cellpadding="0">
	<tr>
		
    <td> <h1 align="center"><img src="Afbeeldingen/AanmeldTitel.gif" width="402" height="83"></h1>
		</td>
	</tr>
</table>
<br>
<table width="100%" border="0" cellspacing="2" cellpadding="0">
  <tr>
    <th><table class="navi" width="100%" border="1" cellspacing="0" cellpadding="0">
        <tr>
          <td width="15%" bgcolor="#D7D7D7">
		  	Cursus<br>
		  	<hr>
			<?php
				$db = mysql_connect("localhost", "xxxx", "") or die ("Verbinding mislukt");
				mysql_select_db ("xxxxxxx",$db);
				$SQL_statement = "SELECT * FROM `tblInhoudCursus`";
				$resultset = mysql_query($SQL_statement);
				$count_rows = mysql_num_rows($resultset);
				
				while($data= mysql_fetch_array($resultset)){
				echo '<a href="' . $data['Link'] . '">' . $data['Omschrijving'] . "</a><br>\n";
				}
				mysql_close();
			?>

This is my css for the link:

Code:
a:link {
	color: #000000;
	text-decoration: none;
}
 

I see you have used uppercase for the file name of the linked style sheet (Site.css). Is it possible that your style sheet file name doesn't use that capitalisation?

Some operating systems treat "Site.css" and "site.css" as two very different files. I say this because everything else appears fine!

Jeff

 
Well the link is correct, because my tables look fine but they are also made in HTML-code. If I make a link in HTML-code it gets the profile I made in CSS. When I make the same link in php it doesn't. I don't get it.
 
Remember, you might get different renderings depending on the state of the link....

Has it been visited? Is it active?

Throw a regular "html" link at the bottom of the page.
Something you know you haven't visited.

If it gets the correct properties you can know your style
sheet is intact.

Good Place to "Learn More">>
W3 Schools
 
I didn't think about that tnx. I forgot to make a visited profile in css. Now it works.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top