Help with css + php

C++, C#, Java, PHP, ect...
Post Reply
gama-slug
Posts: 38
Joined: Thu May 06, 2010 2:58 am

Help with css + php

Post 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
Jony
Posts: 26
Joined: Tue May 11, 2010 3:34 pm

Re: Help with css + php

Post 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.
Last edited by Jony on Sun May 16, 2010 9:42 am, edited 1 time in total.
User avatar
Torniquet
Posts: 869
Joined: Sun Aug 02, 2009 6:18 am

Re: Help with css + php

Post 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
New Site Coming Soon! Stay tuned :D
User avatar
hallsofvallhalla
Site Admin
Posts: 12026
Joined: Wed Apr 22, 2009 11:29 pm

Re: Help with css + php

Post 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 .
gama-slug
Posts: 38
Joined: Thu May 06, 2010 2:58 am

Re: Help with css + php

Post by gama-slug »

thank you that helped alot. I couldnt figure it out for the life of me lol.
Post Reply

Return to “Coding”