SitePoint Sponsor

User Tag List

Results 1 to 10 of 10
  1. #1
    SitePoint Guru
    Join Date
    Feb 2006
    Location
    Chepstow, South Wales
    Posts
    906
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Image path with php variable as height and width.

    I have a few module icons, and in the database the full path is placed in there and its called onto the website in its entirity.
    It was working fine until i wanted to control the height and width through variables and then the icon no longer shows.

    This is the image code and path as I have it in the database.

    Code:
    <img src="images/ModuleIcons/Colour/food.png" alt="FoodCheck Module - Certified" border="0" class="moduleIcon" height="<?= $icon_Height ?>" width="<?= $icon_Width ?>" />
    Which worked fine with the following code below, until i wanted to control the height and width through php.

    Code:
    $icon_Height='57px';
    $icon_Width='56px';
    
    <a href="javascript:popUp('<? echo "standdata.php?srno=$q[Id_Stand]"; ?>','')" title="<?=$q['stand_Name']?>"><? echo $q['Nom_Stand']?></a>
    But now the icon wont show at all.

  2. #2
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,063
    Mentioned
    152 Post(s)
    Tagged
    0 Thread(s)
    What is the HTML output (perform a view-source and copy the img tag here) that is generated from your code?
    Be sure to congratulate Patche on earning July's Member of the Month
    Go ahead and blame me, I still won't lose any sleep over it
    My Blog | My Technical Notes

  3. #3
    SitePoint Guru
    Join Date
    Feb 2006
    Location
    Chepstow, South Wales
    Posts
    906
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi cpradio,

    <a href="javascriptopUp('standdata.php?srno=10','')" title="Food Safety"><img src="images/ModuleIcons/Colour/food.png" alt="FoodCheck Module - Certified" border="0" class="moduleIcon" height="<?= $icon_Height ?>" width="<?= $icon_Width ?>" /></a>

    Thats the HTML output...

  4. #4
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,063
    Mentioned
    152 Post(s)
    Tagged
    0 Thread(s)
    Okay, so why isn't it parsing the <?= $icon_Height ?> and <?= $icon_Wdith ?> tags? Do you have them within a PHP file?
    Be sure to congratulate Patche on earning July's Member of the Month
    Go ahead and blame me, I still won't lose any sleep over it
    My Blog | My Technical Notes

  5. #5
    SitePoint Guru
    Join Date
    Feb 2006
    Location
    Chepstow, South Wales
    Posts
    906
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yep, strange isnt it...

    They placed at the top of the page with the other variables.

    <?
    $icon_Height="57px";
    $icon_Width="56px";
    ?>

    http://devchecksafetyfirst.csf.dcman...otel_ID=246687

    On the right side, where it says compliant with these standards should be the lone icon that should be showing which is the only one im trying it out on at the mo

  6. #6
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,063
    Mentioned
    152 Post(s)
    Tagged
    0 Thread(s)
    Yes, but the PHP isn't being parsed. I feel like something is missing here, are you pulling the img tag from an external source (including it, ajax, etc)?
    Be sure to congratulate Patche on earning July's Member of the Month
    Go ahead and blame me, I still won't lose any sleep over it
    My Blog | My Technical Notes

  7. #7
    SitePoint Guru
    Join Date
    Feb 2006
    Location
    Chepstow, South Wales
    Posts
    906
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No the full path:

    <img src="images/ModuleIcons/Colour/food.png" alt="FoodCheck Module - Certified" border="0" class="moduleIcon" height="<?= $icon_Height ?>" width="<?= $icon_Width ?>" />

    Is in the database under Nom_Stand...

    Then on the page the variables are declared at the top:

    $icon_Height="57px";
    $icon_Width="56px";

    Then this is the code in the HTML calling that img path.

    Code:
    <div id="hotel_Picture_Section_Right_Right">Compliant with these standards<br/>
    <?
    $y=mysql_query("select tbl_standards.Id_Stand, tbl_standards.Nom_Stand, tbl_standards.stand_Name FROM tbl_standards LEFT JOIN tbl_hotnstand ON (tbl_hotnstand.Id_Stand=tbl_standards.Id_Stand) WHERE tbl_hotnstand.Id_Hot=".$hotelID." AND (tbl_standards.Id_View='1') GROUP by tbl_standards.Nom_Stand");  
    while($q=mysql_fetch_assoc($y)){ ?>
    <? if ($q['Id_Stand'] == '18' ) { ?>
    
    <? } else { ?>
    <a href="javascript:popUp('<? echo "standdata.php?srno=$q[Id_Stand]"; ?>','')" title="<?=$q['stand_Name']?>"><? echo $q['Nom_Stand']?></a>
    <? } ?>
    <? } ?>
    </div>

  8. #8
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,063
    Mentioned
    152 Post(s)
    Tagged
    0 Thread(s)
    Ah, I see. so the value from the database is
    Code:
    <img src="images/ModuleIcons/Colour/food.png" alt="FoodCheck Module - Certified" border="0" class="moduleIcon" height="<?= $icon_Height ?>" width="<?= $icon_Width ?>" />
    That is why the variables are not being parsed. That would be a HUGE security risk if PHP parsed that data.

    You'll want to do a str_replace
    PHP Code:
    $imageTag = '<img src="images/ModuleIcons/Colour/food.png" alt="FoodCheck Module - Certified" border="0" class="moduleIcon" height="<?= $icon_Height ?>" width="<?= $icon_Width ?>" />';
    $imageTag = str_replace('<?= $icon_Height ?>', $iconHeight, $imageTag);
    $imageTag = str_replace('<?= $icon_Width ?>', $iconWidth, $imageTag);
    Be sure to congratulate Patche on earning July's Member of the Month
    Go ahead and blame me, I still won't lose any sleep over it
    My Blog | My Technical Notes

  9. #9
    SitePoint Guru
    Join Date
    Feb 2006
    Location
    Chepstow, South Wales
    Posts
    906
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Oh right I see, so you cant do that can you?

    Thanks cpradio, will use the str_replace as you say.

    Will have to do it this way -

    Code:
    <?
    $imageTag = $q['Nom_Stand'];
    $imageTag = str_replace('<?= $icon_Height ?>', $icon_Height, $imageTag);
    $imageTag = str_replace('<?= $icon_Width ?>', $icon_Width, $imageTag);
    ?> 
    
    <a href="javascript:popUp('<? echo "standdata.php?srno=$q[Id_Stand]"; ?>','')" title="<?=$q['stand_Name']?>"><?=$imageTag?></a>
    Seems tohave worked out, thanks cpradio once again

  10. #10
    SitePoint Mentor bronze trophy
    John_Betong's Avatar
    Join Date
    Aug 2005
    Location
    City of Angels
    Posts
    1,805
    Mentioned
    73 Post(s)
    Tagged
    6 Thread(s)
    Quote Originally Posted by multichild View Post
    Yep, strange isnt it...

    They placed at the top of the page with the other variables.

    <?
    $icon_Height="57px";
    $icon_Width="56px";
    ?>

    http://devchecksafetyfirst.csf.dcman...otel_ID=246687

    On the right side, where it says compliant with these standards should be the lone icon that should be showing which is the only one im trying it out on at the mo
    Just validated your site and there are numerous errors which may be causing your problems:

    http://validator.w3.org/check?uri=ht...Inline&group=0


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •