Jump to content

aebuell

New Members
  • Posts

    5
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

aebuell's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I have confirmed that the $_SESSION variables contained the correct values,  but now I'm thinking that I am probably setting them in the wrong place. I had a loop to check all possible values to see if they were set, but here's an example I used immediately after the above code I had posted, just to see if I could get one to work: if(isset($_POST['option_select0']))       {         $_SESSION['OptionID0'] = $option_results[0]['OptionID'];                                                            } I did that because it worked for my drop-down boxes, but the drop-down boxes are using the onChange='this.form.submit()' attribute whereas the check boxes are not.  I didn't want the screen to re-load every time the user checks an option although that would have been a lot easier to program. So the $_SESSION variables are being set correctly, I think it's just that at the point of being compared they have not yet been set. I'll go try some things. Thanks a bunch for your help.
  2. Some of the html in my code didn't display correctly. In the debugging statements there is an  echo "<br>" between each line. How do I display code anyway?
  3. see the display here: http://retain.iusb.edu/studebaker/visitor/work_in_progress problem is that options do not remain checked once form is submitted. I want to store a session variable for each option selected. Having a little difficulty since there is no way of telling how many options the user will select. code: // get_option_data() returns the 'OptionID' and 'Name' fields for each result. $option_results = get_option_data($_SESSION['MakeID'], $_SESSION['ModelID'],                                    $_SESSION['Year'], $_SESSION['FrameID'],                                    $_SESSION['ColorID'], $_SESSION['InteriorID'],                                    $_SESSION['PackageID']);                                       echo "<table border = \"0\" cellpadding = \"8\">";     if(sizeof($option_results) > 0)    {        $i = 0;        while($i < sizeof($option_results))        {            echo "<tr>";            for ($j = 0; $j < 2; $j++)  // Options are displayed in a table with 2 columns            {              echo "<td width = \"225\">";                            if ($i < sizeof($option_results))    // Need to check this again within the for loop              {                $OptionID = $option_results[$i]['OptionID'];                  $OptionName = $option_results[$i]['Name'];                                  $name = "\"option_select" . $i . "\"";                  $index = "'OptionID" . $i . "'";                                       // ***********  D E B U G G I N G  S T A T E M E N T S ************                //echo "\$_SESSION['OptionID0'] is " . $_SESSION['OptionID0'];                //echo "<br />";                //echo "\$index is " . $index;                //echo "<br />";                //echo "\$_SESSION[\$index] is " . $_SESSION[$index];                //echo "<br />";                //echo "\$OptionID is $OptionID";                //echo "<br />";              // *******************************************************                                echo "<input type = \"checkbox\" name = $name value=\"$OptionID\"";                if($OptionID == $_SESSION[$index])                    echo " checked ";                echo ">$OptionName";                }                            echo "</td>";                            $i++;        }          echo "</tr>";        }      }
  4. New here - I hope someone can help. I want to compare $OptionID and $_SESSION[$index]. This is in a loop, where $index is equal to 'OptionID0', 'OptionID1', etc. My if statement wasn't returning true when it should have. I have this debugging output from the loop:     $_SESSION['OptionID0'] is 1     $index is 'OptionID0'     $_SESSION[$index] is     $OptionID is 1 Since $OptionID is 1, and $_SESSION['OptionID0'] is 1, and $index = 'OptionID0', you would think $_SESSION[$index]  should be 1. But its output is blank. Anyone know why this doesn't work? Got a workaround? Thanks a bunch. -Abby
  5. I just found this code the other day. Works great. It is written to create thumbnails for an entire directory. Maybe you could modify it for your purposes. I did not see the author's name or any restrictions on its use. Place it in your regular picture directory. Running it will create a thumbnail with the prefix "tn_" for each image and place it in a directory within the regular picture directory called "thumbs". You'd just have to change the name in this line of code to reflect whatever you want your thumb directory called: createthumb($p,"thumbs/tn_".$p,150,150); I don't keep thumb info in my database. Just info for the full-sized images. When I want to work with a thumb I start with the filename of the full-sized image, like this: $ImageFile_thumb = "tn_" . $ImageFileName; Also I could not get this to work without making the thumb directory permissions 777. Here is the code: <?php $imagefolder='.'; $thumbsfolder='.'; $pics=directory($imagefolder,"jpg,JPG,JPEG,jpeg,png,PNG"); $pics=ditchtn($pics,"tn_"); if ($pics[0]!="") { foreach ($pics as $p) { createthumb($p,"thumbs/tn_".$p,150,150); } } //************************** D I T C H  T N ***************************** // filters out thumbnails function ditchtn($arr,$thumbname) { foreach ($arr as $item) { if (!preg_match("/^".$thumbname."/",$item)){$tmparr[]=$item;} } return $tmparr; } // ************************ C R E A T E  T H U M B ********************** // creates a resized image // variables: // $name Original filename // $filename Filename of the resized image // $new_w width of resized image // $new_h height of resized image function createthumb($name,$filename,$new_w,$new_h) { $system=explode(".",$name); if (preg_match("/jpg|jpeg/",$system[1])){$src_img=imagecreatefromjpeg($name);} if (preg_match("/png/",$system[1])){$src_img=imagecreatefrompng($name);} $old_x=imageSX($src_img); $old_y=imageSY($src_img); if ($old_x > $old_y) { $thumb_w=$new_w; $thumb_h=$old_y*($new_h/$old_x); } if ($old_x < $old_y) { $thumb_w=$old_x*($new_w/$old_y); $thumb_h=$new_h; } if ($old_x == $old_y) { $thumb_w=$new_w; $thumb_h=$new_h; } $dst_img=ImageCreateTrueColor($thumb_w,$thumb_h); imagecopyresampled($dst_img,$src_img,0,0,0,0,$thumb_w,$thumb_h,$old_x,$old_y); if (preg_match("/png/",$system[1])) { imagepng($dst_img,$filename); } else {   imagejpeg($dst_img,$filename); } imagedestroy($dst_img); imagedestroy($src_img); } //*********************** D I R E C T O R Y ***************************** //  reads the content of $directory, takes the files that apply to $filter // and returns an array of the filenames. //  You can specify which files to read, for example //  $files = directory(".","jpg,gif"); //  gets all jpg and gif files in this directory. //  $files = directory(".","all"); //  gets all files. function directory($dir,$filters) { $handle=opendir($dir); $files=array(); if ($filters == "all"){while(($file = readdir($handle))!==false){$files[] = $file;}} if ($filters != "all") { $filters=explode(",",$filters); while (($file = readdir($handle))!==false) { for ($f=0;$f<sizeof($filters);$f++): $system=explode(".",$file); if ($system[1] == $filters[$f]){$files[] = $file;} endfor; } } closedir($handle); return $files; } ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.