Description: This WebSmart PHP example resizes the width of an image to the value that $maxwidth is set too.
In this case the image has been resized to 300px by 80px.
Enter Contents Here
-
Start WebSmart go to File->New. In the new window select PHP Templates-> iSeries SQL-> Idaho-> A Simple Page.tpl" and create a simple page.
-
Go to Attributes->Files, type in MU_ITMF for the file and XL_WEBDEMO for the file library. Click OK, and OK again.
-
In the PHP-Source Code tab, near the top replace:
     
global $wsnum;
With the following:
     
global $wsnum, $a, $width, $height, $arr1, $maxwidth, $value;
-
In the PHP-Source Code, function generic() add the below code immedately before wrtseg('MainSeg');
   
    foreach($GLOBALS as $arraykey => $arrayvalue)
    {
    if ($arraykey[0]!='_' && $arraykey != 'GLOBALS')
            global $$arraykey;
        }
    $maxwidth=300;
    if (file_exists($a)){
      $arr1 = getimagesize("http://esdi.excelsystems.com/websmart/Images/cloverquery50.gif");
      $width=$arr1[0];
    $height=$arr1[1];
    if($width > $maxwidth || $width ==0){
      $height = ($maxwidth/$width)*$height;
      $width = $maxwidth;
     
    }
    $a= "http://esdi.excelsystems.com/websmart/Images/cloverquery160x600.gif";
    }
   
    else{
   
    $a = "http://esdi.excelsystems.com/websmart/Images/cloverquery160x600.gif";
    $arr1 = getimagesize("http://esdi.excelsystems.com/websmart/Images/cloverquery160x600.gif");
    $width = $arr1[0];
    $height = $arr1[1];
    if ($width > $maxwidth|| $width == 0) {
        $height = ($maxwidth/$width)*$height;
        $width = $maxwidth;
    }
    $a = "/websmart/Images/cloverquery160x600.gif";
    }
   
   
6.b.)So it looks like:
    function generic()
    {
    foreach($GLOBALS as $arraykey => $arrayvalue)
    {
      if ($arraykey[0]!='_' && $arraykey != 'GLOBALS')
        global $$arraykey;
    }
   
   
    $maxwidth=300;
    if (file_exists($a)){
      $arr1 = getimagesize("http://esdi.excelsystems.com/websmart/Images/cloverquery50.gif");
      $width=$arr1[0];
      $height=$arr1[1];
        if($width > $maxwidth || $width ==0){
       $height = ($maxwidth/$width)*$height;
       $width = $maxwidth;
   
      }
        $a= "http://esdi.excelsystems.com/websmart/Images/cloverquery160x600.gif";
    }
   
   
    else{
   
    $a = "http://esdi.excelsystems.com/websmart/Images/cloverquery160x600.gif";
    $arr1 = getimagesize("http://esdi.excelsystems.com/websmart/Images/cloverquery160x600.gif");
    $width = $arr1[0];
    $height = $arr1[1];
    if ($width > $maxwidth || $width == 0) {
    $height = ($maxwidth/$width)*$height;
    $width = $maxwidth;
    }
    $a = "/websmart/Images/cloverquery160x600.gif";
    }
   
    wrtseg('MainSeg');
    }
   
- In the MainSeg tab , immediately after the < div id="contents"> add the following:
    <?php
        echo "< img width =$width height = $height src=\"" . $a . "\">";
    ?>
    </div>
      </div> </div>
   
So it looks like:
    < div id="contents">
    Enter Content Here
    <?php
    echo "< img width =$width height = $height src=\"" . $a . "\">";
    ?>
   
    </div>
    </div>   </div>
    </li>
    < div class="dhtmlgoodies_aTab">
|