Page 1 of 1
PHP if and CSS Sugestions
Posted: Sat Feb 27, 2010 3:39 am
by tragedy
Hello,
for example
if li id="71" -->
a id="menu" style="background:red;"
How can I do it with PHP
Thank you...
Re: PHP if and CSS Sugestions
Posted: Sat Feb 27, 2010 9:12 am
by social_experiment
If you pass the 'id' in the php, example :
Code: Select all
<?php $id = 1;
echo "<li id=\"$id\">arbtext</li>";
?>
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
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;
}
} ?>
You then have the function between the <style> tags.
Code: Select all
<style>
<?php changeLiElements($id); ?>
</style>
Re: PHP if and CSS Sugestions
Posted: Sat Feb 27, 2010 10:32 am
by tragedy
social_experiment wrote:If you pass the 'id' in the php, example :
Code: Select all
<?php $id = 1;
echo "<li id=\"$id\">arbtext</li>";
?>
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
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;
}
} ?>
You then have the function between the <style> tags.
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;})
Re: PHP if and CSS Sugestions
Posted: Sat Feb 27, 2010 11:50 am
by social_experiment
if li id="71" -->
a id="menu" style="background:red;"
Your question was a bit vague. Try javascript.
Re: PHP if and CSS Sugestions
Posted: Sat Feb 27, 2010 1:32 pm
by tragedy
social_experiment wrote:if li id="71" -->
a id="menu" style="background:red;"
Your question was a bit vague. Try javascript.
Yes , u're right. Sorry for my English.
Could you help me, how can i do with js?
Thank you.