sorensens Posted June 28, 2006 Share Posted June 28, 2006 Hi ^.^ For some reason my brain's just not computing to do this. Basically what I'm looking for is making it so that "admins" have one color in links while "members" have a different color. This is the code I'm working woth right now:[code]$query = "select member_status from membership where name = '$member'";$result = mysql_query($query) or die(mysql_error());$member_status = mysql_result($result, 0);if ($member_status=='2') {// Etc... [/code]Right now I import a CSS/PHP page to change how everything looks and I was hoping to add two classes there to use for how the admin and member links look. Quote Link to comment https://forums.phpfreaks.com/topic/13157-altering-link-class/ Share on other sites More sharing options...
SharkBait Posted June 28, 2006 Share Posted June 28, 2006 I think you have the idea pretty much.[code]<?php// Check to see the status of the userif($member_status == '2') { // User is Admin $style = "adminStyle";} else { // User is Not Admin $style = "regularStyle";}?><a class="<?php echo $style;?> href="#""> First Link</a>[/code]So now if your an Admin it will look like[code]<a class="adminStyle" href="#">First Link</a>[/code]and if your Not an Admin[code]<a class="regularStyle" href="#">First Link</a>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/13157-altering-link-class/#findComment-50606 Share on other sites More sharing options...
sorensens Posted June 29, 2006 Author Share Posted June 29, 2006 [!--quoteo(post=389036:date=Jun 28 2006, 04:26 PM:name=SharkBait)--][div class=\'quotetop\']QUOTE(SharkBait @ Jun 28 2006, 04:26 PM) [snapback]389036[/snapback][/div][div class=\'quotemain\'][!--quotec--]I think you have the idea pretty much.[code]<?php// Check to see the status of the userif($member_status == '2') { // User is Admin $style = "adminStyle";} else { // User is Not Admin $style = "regularStyle";}?><a class="<?php echo $style;?> href="#""> First Link</a>[/code]So now if your an Admin it will look like[code]<a class="adminStyle" href="#">First Link</a>[/code]and if your Not an Admin[code]<a class="regularStyle" href="#">First Link</a>[/code][/quote]^.^ Thank you for helping. My only problem left now is that my link is being echo'd already from inside the php and I can't figure out how to get it to echo within double quotes.ex. this is the specific line I'm changing [code]<a href="viewprofile.php?id='.$id.'" class='.$style.'>'.$name.'</a> [/code] Quote Link to comment https://forums.phpfreaks.com/topic/13157-altering-link-class/#findComment-50664 Share on other sites More sharing options...
redarrow Posted June 29, 2006 Share Posted June 29, 2006 [!--quoteo(post=389094:date=Jun 29 2006, 03:50 AM:name=Sorensen)--][div class=\'quotetop\']QUOTE(Sorensen @ Jun 29 2006, 03:50 AM) [snapback]389094[/snapback][/div][div class=\'quotemain\'][!--quotec--]^.^ Thank you for helping. My only problem left now is that my link is being echo'd already from inside the php and I can't figure out how to get it to echo within double quotes.ex. this is the specific line I'm changing [code]<a href="viewprofile.php?id='.$id.'" class='.$style.'>'.$name.'</a> [/code][/quote]<a href="viewprofile.php?id='.$id.'" class='.$style.'>'".$name."'</a> Quote Link to comment https://forums.phpfreaks.com/topic/13157-altering-link-class/#findComment-50667 Share on other sites More sharing options...
sorensens Posted June 29, 2006 Author Share Posted June 29, 2006 [!--quoteo(post=389097:date=Jun 28 2006, 10:22 PM:name=redarrow)--][div class=\'quotetop\']QUOTE(redarrow @ Jun 28 2006, 10:22 PM) [snapback]389097[/snapback][/div][div class=\'quotemain\'][!--quotec--]<a href="viewprofile.php?id='.$id.'" class='.$style.'>'".$name."'</a>[/quote]Sorry, what I meant to say was that the link when you view source looks like -<a href="viewprofile.php?id='.$id.'" class=adminStyle>'.$name.'</a> So the class isn't working :( Quote Link to comment https://forums.phpfreaks.com/topic/13157-altering-link-class/#findComment-50687 Share on other sites More sharing options...
heckenschutze Posted June 29, 2006 Share Posted June 29, 2006 rather than changing all of your links, an easier way would be to change the link class.eg..[code]//** Goes inbetween the "head" tags of your document.echo "<style type=\"text/css\">";if($member_status == 2){ echo "a:link {}"; //** Starting example, Admin link styles goes here}else{ echo "a:link {}"; //** Starting example, User link styles goes here}echo "</style>";[/code]OR you could include a different stylesheet. eg, an "extra" one.hth, Zac. Quote Link to comment https://forums.phpfreaks.com/topic/13157-altering-link-class/#findComment-50717 Share on other sites More sharing options...
sorensens Posted June 29, 2006 Author Share Posted June 29, 2006 [!--quoteo(post=389147:date=Jun 29 2006, 01:31 AM:name=heckenschutze)--][div class=\'quotetop\']QUOTE(heckenschutze @ Jun 29 2006, 01:31 AM) [snapback]389147[/snapback][/div][div class=\'quotemain\'][!--quotec--]rather than changing all of your links, an easier way would be to change the link class.eg..[code]//** Goes inbetween the "head" tags of your document.echo "<style type=\"text/css\">";if($member_status == 2){ echo "a:link {}"; //** Starting example, Admin link styles goes here}else{ echo "a:link {}"; //** Starting example, User link styles goes here}echo "</style>";[/code]OR you could include a different stylesheet. eg, an "extra" one.hth, Zac.[/quote]:/ I need to use the link from before though - there's only one link as it's from my usersonline. The style isn't giving me the problem it's applying the style to the link that's not working since I can't just put something like [code]class=" '.$style.' "[/code] Quote Link to comment https://forums.phpfreaks.com/topic/13157-altering-link-class/#findComment-50822 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.