Dhar
Dhar

Reputation: 47

Including CSS for a DIV in PHP

if(boothsizerGlobal ==  3){
    var cellWidth = 112;
    var cellHeight = 52;
    var innerDivElectricTop = 41; 
    var innerDivElectricLeft =  110;    
    $('.imgBox').css("background-image", "url(booth_top_images/5X20TOP.jpg)");
    $('.imgBox').css("width", "900px");
    $('.imgBox').css("height", "225px");
    sidewalls = 2;
    backwalls = 6;  

}

Can anybody help me on converting above code into PHP? I mean how to set CSS for a DIV in more than 40 if conditions I have?

Thanks

Upvotes: 0

Views: 64

Answers (2)

What have you tried
What have you tried

Reputation: 11138

Well, your original code made no sense to begin with as half of the declared variables weren't even being used. Furthermore, it is beyond me why you'd want to convert front-end code into server-side code like this, php is not the right way to do this!

if(boothsizerGlobal ==  3){
    $cellWidth = '112px';
    $cellHeight = '52px';
    $innerDivElectricTop = '41px'; 
    $innerDivElectricLeft =  '110px';    
    $backgroundImage = 'url(booth_top_images/5X20TOP.jpg)';

    $divCode = '<div style="width: ' . $cellWidth . '; height: ' . $cellHeight . '; "';
    return $divCode

}

Upvotes: 0

Akhil Thesiya
Akhil Thesiya

Reputation: 950

.imgBox
{
background:url(booth_top_images/5X20TOP.jpg) no-repeat; 
width:900px;
height:225px;
}

Upvotes: 1

Related Questions