Page 1 of 1

Help with css + php

Posted: Sun May 16, 2010 12:53 am
by gama-slug
if my coding looks bad sorry im new to php

What i am trying to do is get $left to work as the number for the left in the css code if that makes sense

This way i can do a variable for left and top depending on the picture it is going to use.

Basically what i am doing is i have a paper doll system when the change weapons each weapon picture is alittle different in size and i need the top and left to change for each picture

this is what i am calling the image foward in

Code: Select all

   <?php
   $playerwepim = $playerinfo3['WeaponImage'];
   ?>
<div id="wepim">
   <?php
echo "<img src='$playerwepim'>";
  ?>
</div>
this is what i was trying to use in css file

Code: Select all

 <?php  
 header("Content-type: text/css; charset: UTF-8");  
   
   $left  = "10";

 );  

   ?>

body {
	background-color: #ffffff;
}




#wepim {
	position:absolute;
	left: <?php echo $left; ?>px; 
	top:525px;
	width:93px;
	height:160px;

	z-index:1;
	text-align:left;
}
currently no matter what i set it to the picture dosnt move to the left at all just sits all the way to the right like if i set left to 0

if i can not do that is there a way for me to override the left and top in a php script like when i tell it what to put in #wepim

Re: Help with css + php

Posted: Sun May 16, 2010 9:37 am
by Jony
I'm not sure, but i think that you should assign the value of the $left as an integer, not as a string.

try $left=10;

Also another error that i see that that ");" floating arround after the variable $left is assigned as a string in your code.

Re: Help with css + php

Posted: Sun May 16, 2010 9:41 am
by Torniquet

Code: Select all

<div style="position:absolute; top:0; left:<php? echo $left; ?>px;">
    content in here.
</div>
in order to have the absolute div looking right you will also need to have a div with a position of relative wrapped around all your weapon images. for eg.

Code: Select all

<div style="position:relative; height:300px; width:150px;" id="WeaponWrap">
    <div style="position:absolute; top:<?php echo $weaponTop; ?>px; left:<?php echo $weaponLeft;?>px;" id="weapon">
    </div>
    <div style="position:absolute; top:<?php echo $shieldTop; ?>px; left:<?php echo $shieldLeft;?>px;" id="shield">
    </div>
</div>
hope this answers your question

Re: Help with css + php

Posted: Sun May 16, 2010 12:47 pm
by hallsofvallhalla
yes you have to change the image location in the actual php page and not css. You your php will not be recognized. So just change set the location when you define the image .

Re: Help with css + php

Posted: Sun May 16, 2010 11:53 pm
by gama-slug
thank you that helped alot. I couldnt figure it out for the life of me lol.