Jump to content

Recommended Posts

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.
Link to comment
https://forums.phpfreaks.com/topic/13157-altering-link-class/
Share on other sites

I think you have the idea pretty much.

[code]
<?php
// Check to see the status of the user
if($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]


Link to comment
https://forums.phpfreaks.com/topic/13157-altering-link-class/#findComment-50606
Share on other sites

[!--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 user
if($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]
Link to comment
https://forums.phpfreaks.com/topic/13157-altering-link-class/#findComment-50664
Share on other sites

[!--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>
Link to comment
https://forums.phpfreaks.com/topic/13157-altering-link-class/#findComment-50667
Share on other sites

[!--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 :(
Link to comment
https://forums.phpfreaks.com/topic/13157-altering-link-class/#findComment-50687
Share on other sites

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.
Link to comment
https://forums.phpfreaks.com/topic/13157-altering-link-class/#findComment-50717
Share on other sites

[!--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]
Link to comment
https://forums.phpfreaks.com/topic/13157-altering-link-class/#findComment-50822
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.