Jump to content


Photo

Mixing CSS and PHP


  • Please log in to reply
6 replies to this topic

#1 Mouse

Mouse
  • Members
  • PipPipPip
  • Advanced Member
  • 95 posts
  • LocationToo Close to LONDON

Posted 16 March 2006 - 10:35 PM

Hello all....

this is going to be so obviouse but i just cant see it....

this works...

<style type="text/css">
#menu {position:relative; top:10px; left:100px; width:75px; background-color:#fff; z-index:100;}
#menu a.p1, #menu a.p1:visited {display:block; width:75px; height:75px; text-decoration:none; background:#fff; top:0; left:0; border:0;}
#menu a img {border:0;}
#menu a.p1:hover {text-decoration:none; background-color:#8c97a3; color:#000;}
#menu a .large {display:block; position:absolute; width:1px; height:1px; border:0px; top:-1px; left:-1px;}
#menu a.p1:hover .large {display:block; position:absolute; top:-60px; left:150px; width:300px; height:300px; border:10px solid #fff;}
#info {z-index:100; height:10em;}
</style>
</head>

<body>

<div id="menu">
<a class="p1" href="#nogo" title="thumbnail image"><img src="images/mugs/img1.jpg" title="Thumbnail image" alt="Thumbnail image" /><img class="large"  src="images/mugs/img1.jpg" title="Enlarged view of image" alt="Enlarged view of image" /></a>
</div>
</body>
</html>

but this don't....

<?php
      $filename = "images/mugs/".$familyname."_".$firstname.".jpg";
      $filename = strtolower($filename);
      
      if (file_exists($filename)) {
      echo "<!-- looking for image: $filename -->\n";
      
echo '<div id="menu">';
echo '<a class="p1" href="#nogo" ><img src=\"$filename\" /><img class="large"  src=\"$filename\" /></a>';
echo '</div>';

      } else {
      echo "<!-- looking for filename: $filename -->\n";
      echo "<img src=\"images/mugs/MugDefault.jpg\" width=\"135\" height=\"150\" >";
      } 
      ?>

WHY????????

please help me here before i tear my hair out (i don't look good without my foppish hair style...)

Mouse

#2 fusionpixel

fusionpixel
  • Members
  • PipPipPip
  • Advanced Member
  • 64 posts

Posted 16 March 2006 - 10:45 PM

Close but no quite there yet ;)

<?php
      $filename = "images/mugs/".$familyname."_".$firstname.".jpg";
      $filename = strtolower($filename);
      
      if (file_exists($filename)) {
        echo "<!-- looking for image: $filename -->\n";
        echo '<div id="menu">';
        echo '<a class="p1" href="#nogo" ><img src="'.$filename.'" /><img class="large"  src="'.$filename.'" /></a>';
        echo '</div>';
      } else {
      echo "<!-- looking for filename: $filename -->\n";
      echo "<img src=\"images/mugs/MugDefault.jpg\" width=\"135\" height=\"150\" >";
      }
?>

You need to get those variables out of the quotes.
Did you know there is a manual for PHP? [a href="http://" target="_blank"]http://www.php.net[/a]
Did you know there is a manual for mySQL? [a href="http://" target="_blank"]http://www.mysql.org[/a]

#3 Mouse

Mouse
  • Members
  • PipPipPip
  • Advanced Member
  • 95 posts
  • LocationToo Close to LONDON

Posted 16 March 2006 - 11:07 PM

[!--quoteo(post=355708:date=Mar 16 2006, 10:45 PM:name=fusionpixel)--][div class=\'quotetop\']QUOTE(fusionpixel @ Mar 16 2006, 10:45 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
Close but no quite there yet ;)

<?php
      $filename = "images/mugs/".$familyname."_".$firstname.".jpg";
      $filename = strtolower($filename);
      
      if (file_exists($filename)) {
        echo "<!-- looking for image: $filename -->\n";
        echo '<div id="menu">';
        echo '<a class="p1" href="#nogo" ><img src="'.$filename.'" /><img class="large"  src="'.$filename.'" /></a>';
        echo '</div>';
      } else {
      echo "<!-- looking for filename: $filename -->\n";
      echo "<img src=\"images/mugs/MugDefault.jpg\" width=\"135\" height=\"150\" >";
      }
?>

You need to get those variables out of the quotes.
[/quote]


now i just get two images just the same.. no image enlargement on mouseover.... :( GRRRRR bed time... come back tommorrow with clear head....

Thanks for the assist tho fusionpixel

Mouse

#4 fusionpixel

fusionpixel
  • Members
  • PipPipPip
  • Advanced Member
  • 64 posts

Posted 16 March 2006 - 11:14 PM

[!--quoteo(post=355714:date=Mar 16 2006, 05:07 PM:name=Mouse)--][div class=\'quotetop\']QUOTE(Mouse @ Mar 16 2006, 05:07 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
now i just get two images just the same.. no image enlargement on mouseover.... :( GRRRRR bed time... come back tommorrow with clear head....

Thanks for the assist tho fusionpixel

Mouse
[/quote]

yup, you will get 2 identical images because that is what you are telling PHP to do:

echo '<a class="p1" href="#nogo" ><img src="'.$filename.'" /><img class="large"  src="'.$filename.'" /></a>';

see? $filename is used twice in there.

hope that helps and have a good nite LOL
Did you know there is a manual for PHP? [a href="http://" target="_blank"]http://www.php.net[/a]
Did you know there is a manual for mySQL? [a href="http://" target="_blank"]http://www.mysql.org[/a]

#5 Mouse

Mouse
  • Members
  • PipPipPip
  • Advanced Member
  • 95 posts
  • LocationToo Close to LONDON

Posted 17 March 2006 - 06:04 AM

[!--quoteo(post=355717:date=Mar 16 2006, 11:14 PM:name=fusionpixel)--][div class=\'quotetop\']QUOTE(fusionpixel @ Mar 16 2006, 11:14 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
yup, you will get 2 identical images because that is what you are telling PHP to do:

echo '<a class="p1" href="#nogo" ><img src="'.$filename.'" /><img class="large"  src="'.$filename.'" /></a>';

see? $filename is used twice in there.

[/quote]

Morning.... yawn!

right, yes the file name is used twice, just as it is in the first code example... the css should work like the example here... [a href=\"http://www.cssplay.co.uk/menu/magnify.html\" target=\"_blank\"][CSS Example][/a]

#6 fusionpixel

fusionpixel
  • Members
  • PipPipPip
  • Advanced Member
  • 64 posts

Posted 17 March 2006 - 07:04 AM

Good morning...

this works for me:
<style type="text/css">
#menu {position:relative; top:10px; left:100px; width:75px; background-color:#fff; z-index:100;}
#menu a.p1, #menu a.p1:visited {display:block; width:75px; height:75px; text-decoration:none; background:#fff; top:0; left:0; border:0;}
#menu a img {border:0;}
#menu a.p1:hover {text-decoration:none; background-color:#8c97a3; color:#000;}
#menu a .large {display:block; position:absolute; width:1px; height:1px; border:0px; top:-1px; left:-1px;}
#menu a.p1:hover .large {display:block; position:absolute; top:-60px; left:150px; width:300px; height:300px; border:10px solid #fff;}
#info {z-index:100; height:10em;}
</style>
</head>

<body>
<?
 echo "<!-- looking for image: $filename -->\n";
      
echo '<div id="menu">';
echo '<a class="p1" href="#nogo" ><img src=\"$filename\" /><img class="large"  src=\"$filename\" /></a>';
echo '</div>';
?>
</body>
</html>

now its my turn :) Yawn! nite...
Did you know there is a manual for PHP? [a href="http://" target="_blank"]http://www.php.net[/a]
Did you know there is a manual for mySQL? [a href="http://" target="_blank"]http://www.mysql.org[/a]

#7 Mouse

Mouse
  • Members
  • PipPipPip
  • Advanced Member
  • 95 posts
  • LocationToo Close to LONDON

Posted 17 March 2006 - 08:43 AM

[!--quoteo(post=355855:date=Mar 17 2006, 07:04 AM:name=fusionpixel)--][div class=\'quotetop\']QUOTE(fusionpixel @ Mar 17 2006, 07:04 AM) View Post[/div][div class=\'quotemain\'][!--quotec--]
now its my turn :) Yawn! nite...
[/quote]

nite nite, sleep tight, hope the bed bugs don't bite.... and many thanks!!!

Mouse





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users