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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I reset the color of a link that has been visited?

Status
Not open for further replies.

Apollo6

Technical User
Jan 27, 2000
418
US
I am fairly new at using HTML and PHP, so please be easy.

Basically, I have a main page that allows a user to make a selection to view certain types of reports. The next page displays all the reports available for viewing. The reports displayed are links to the actual report.

What I would like to do is reset the report link colors if the user closes the browser. When they go back into the main page and select same type of reports and the next page displays, all the report links are "refreshed".

Thanks in advance for any suggestions.
 
In your style sheet...


<style>
a:link, a:visited {text-decoration:none;color:blue;}
a:hover {color:red;}
</style> Get the Best Answers! faq333-2924
&quot;A witty saying proves nothing.&quot; - Voltaire
mikewolf@tst-us.com
 
You will want to have this in the <head> of the page:

<style>
a{color:blue;}
</style>

If you have any
a:visited{color:some_color;}
you need to take them out. Then, each time they click a link, there must be something in the page that comes up to SESSION_REGISTER() the url of that page. Then, for each link, you will have to do a check to see if the url it points to is in SESSION_REGISTER() variable that you used. Write the links using php, and if the url is there--change the color to red, if not, keep it on blue.

Rick -----------------------------------------------------------
 
mwolf00,

I like the hover method...but when I view a report then press the back button the link does not stay red. While the user is toggling between the report list and the reports, I want the links to reflect that they have been visited. I want the links to refresh if the user backs out of the report list page completely.

RISTMO,

With what I just stated, that's where what you posted comes into play. I am using PHP to build the list. I just need to figure out how to do what you said with the SESSION_REGISTER()

Working in the right direction, thanks for the help.
 
First, make sure that you have $var registered as a blank string:
<?
$var=&quot;&quot;;
SESSION_REGISTER(&quot;var&quot;);
?>

I'm not sure what variable contains the url of the page you are viewing, but using php_info(); should tell you. Then, in each page that you view, add this:
<?
$this_url=&quot;page.php&quot;;//or make it dynamic by making it equal the value of the other variable containing the page url
if(!preg_match(&quot;/&quot; . $this_url . &quot;/&quot;,$var)){
$var.=&quot;/&quot; . $this_url . &quot;/&quot;;
}
?>

Then on the page with the list of links:
<?
$next_url=&quot;page.php&quot;;
if(preg_match(&quot;/&quot; . $next_url . &quot;/&quot;,$var)){
print(&quot;<a href=\&quot;&quot; . $next_url . &quot;\&quot; style=\&quot;color:red;\&quot;>link</a>&quot;);//already visited
} else{
print(&quot;<a href=\&quot;&quot; . $next_url . &quot;\&quot; style=\&quot;color:blue;\&quot;>link</a>&quot;);//not visited

}

?>

Might need a little tweaking in addition to the the name that holds the value of the url, but it should be close.

Rick -----------------------------------------------------------
 
Rick,

This is turning into a PHP issue but since it started out as HTML...

OK, I have a total of three pages...

Main Page: rpt_type.php
User selects type of report to view from dropdown.

Page#2: rpt_period.php
User selects available periods for the type of report selected.

Page#3: rpt_name.php
Query is executed and a list is built of available reports. Reports listed are actually links. When a report is selected, Adobe kicks off and displays the pdf report.

In the Main Page, I put the following:
<?
$var=&quot;&quot;;
SESSION_REGISTER(&quot;var&quot;);
?>
As you stated, this will give me a variable to store the reports selected.

In the last page, the one that displays the list of reports, I put the following:
<?
$this_url=$_SERVER['PHP_SELF'];
if(!preg_match(&quot;/&quot; . $this_url . &quot;/&quot;,$var)){
$var.=&quot;/&quot; . $this_url . &quot;/&quot;;
}
?>

<?
$next_url=$_SERVER['PHP_SELF'];
if(preg_match(&quot;/&quot; . $next_url . &quot;/&quot;,$var)){
print(&quot;<a href=\&quot;&quot; . $next_url . &quot;\&quot; style=\&quot;color:red;\&quot;>link</a>&quot;);//already visited
} else{
print(&quot;<a href=\&quot;&quot; . $next_url . &quot;\&quot; style=\&quot;color:blue;\&quot;>link</a>&quot;);//not visited
}
?>

When testing, I get a couple of errors -- &quot;Unknown modifier...&quot; in rpt_name.php. The lines that are causing the errors:

if(!preg_match(&quot;/&quot; . $this_url . &quot;/&quot;,$var)){

if(preg_match(&quot;/&quot; . $next_url . &quot;/&quot;,$var)){

To make sure $this_url is being loaded, I echo it out and verified that it is getting the current page url... I'm just not getting past the error with the Unknown modifier...

I did not add anything to the Second page because there are no links on it, just a dropdown to select from...

I'm still working on it. Thanks again for any help...





 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top