Hello,
for example
if li id="71" -->
a id="menu" style="background:red;"
How can I do it with PHP
Thank you...
PHP if and CSS Sugestions
Moderator: General Moderators
- social_experiment
- DevNet Master
- Posts: 2793
- Joined: Sun Feb 15, 2009 11:08 am
- Location: .za
Re: PHP if and CSS Sugestions
If you pass the 'id' in the php, example :
you could use a case statement. If you use external stylesheets and you want different display for each li element, you will have multiple stylesheets. If you are using an embedded stylesheet (<style></style>), you can let the function create that each time the script is run.
You then have the function between the <style> tags.
Code: Select all
<?php $id = 1;
echo "<li id=\"$id\">arbtext</li>";
?>Code: Select all
function changeLiElements($value) {
switch($value) {
case(1):
echo "background-color : red;"
break;
case(2):
echo "background-color : blue;"
break;
default:
echo "background-color : black;"
break;
}
} ?>Code: Select all
<style>
<?php changeLiElements($id); ?>
</style>“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
Re: PHP if and CSS Sugestions
social_experiment wrote:If you pass the 'id' in the php, example :you could use a case statement. If you use external stylesheets and you want different display for each li element, you will have multiple stylesheets. If you are using an embedded stylesheet (<style></style>), you can let the function create that each time the script is run.Code: Select all
<?php $id = 1; echo "<li id=\"$id\">arbtext</li>"; ?>
You then have the function between the <style> tags.Code: Select all
function changeLiElements($value) { switch($value) { case(1): echo "background-color : red;" break; case(2): echo "background-color : blue;" break; default: echo "background-color : black;" break; } } ?>Code: Select all
<style> <?php changeLiElements($id); ?> </style>
Thanks for responding. But this is not help for me,
Actually I want to change if li id="70" -> a id="23" with CSS (a#23{background:red;})
- social_experiment
- DevNet Master
- Posts: 2793
- Joined: Sun Feb 15, 2009 11:08 am
- Location: .za
Re: PHP if and CSS Sugestions
Your question was a bit vague. Try javascript.if li id="71" -->
a id="menu" style="background:red;"
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
Re: PHP if and CSS Sugestions
Yes , u're right. Sorry for my English.social_experiment wrote:Your question was a bit vague. Try javascript.if li id="71" -->
a id="menu" style="background:red;"
Could you help me, how can i do with js?
Thank you.