Help me!! Please!!

Hi people!! Who help me??? I have this code and i want to select left or right option to float the image to the left or right.
Code:
phpcss.php:

<?php header("Content-type: text/css"); $height = "100px"; $width = "100px"; $bgcolor = "red "; ?>

img{
background: <?php echo $bgcolor; ?>;
width: <?php echo $width; ?>;
height: <?php echo $height; ?>;
float: <?php echo $float; ?>;
text-align: left;
}


Php.php

<?php if(isset($_POST['BtnSubmit'])) { echo "Position : {$_POST['position'] }"; } ?>
  <select name="position">
     <option value=""></option>
     <option value="<img/>" <?php if($_POST['position']=="right") echo "selected=selected"; ?>>Right</option>
     
  </select>
  <br/><br/>

  <input name="BtnSubmit" type="submit" value="Submit">

I personally would do something like this with JavaScript or jQuery and just use PHP to pull in the image.

An why are you using php in your css? That to me doesn’t make any sense. :-\

thanks strider! I’m trying to change the backend of a CMS. I’ll explain better. Once you enter and upload the image ,I need to dynamically change the attribute “float” in the css to move it through a" select "on the right or left.
What do you think?? What is the right way??

the right way is to do something like this:

[php]
.someclass img {
background: red;
width: 100px;
height: 100px;
text-align: left;
}
.pull-left {
float: left;
}
.pull-right {
float: right;
}

<?php // added the pull-left/pull-right styles above as it's default in bootstrap/etc. // set $float to left or right $float = !empty($_POST['position']) && $_POST['position'] == 'right' ? 'right' : 'left'; ?>
[/php]

but yeah, in most situations this would be more suitable to do in JS

Yes JimL!!! Is what i want!!! Can you write me the code with a select box option ??
(I’m beginner with php!!! I need to understand the method))
Thanks JimL

It’s working!!! Thanks JimL and Strider64!!!
See you later!!! ;D

Sponsor our Newsletter | Privacy Policy | Terms of Service