Jump to content

Goose

Members
  • Posts

    2
  • Joined

  • Last visited

Goose's Achievements

Newbie

Newbie (1/7)

0

Reputation

  1. Goose

    PHP Image Resize

    Here is some code for resizing images. It comes from a program I wrote to automatically create galleries from a folder of images. Definately works for jpg. But I saved the thumbnails to my servers harddrive - you could ignore that part and use the imagedestroy function after you've displayed it. Hope this helps.if ($type == "jpg" || $type == "jpeg" || $type == "JPG" || $type == "JPEG"){ $img_source = imagecreatefromjpeg($this->path.$imagename); $oldWidth = imagesx($img_source); $oldHeight = imagesy($img_source); $newHeight = ($newWidth/$oldWidth)*$oldHeight; $img_destination = imagecreatetruecolor($newWidth,$newHeight); imagecopyresized($img_destination,$img_source,0,0,0,0,$newWidth,$newHeight,$oldWidth,$oldHeight); imagejpeg($img_destination,$this->options->thumb_path . "thumb" . $imagename,100); return $this->options->thumb_path . "thumb" . $imagename;}elseif ($type == "gif" || $type == "GIF"){ $img_source = imagecreatefromgif($this->path.$imagename); $oldWidth = imagesx($img_source); $oldHeight = imagesy($img_source); $newHeight = intval((doubleval($newWidth)/doubleval($oldWidth))*$oldHeight); $img_destination = imagecreate($newWidth,$newHeight); imagecopyresized($img_destination,$img_source,0,0,0,0,$newWidth,$newHeight,$oldWidth,$oldHeight); imagegif($img_destination,$this->options->thumb_path . "thumb" . $imagename); return $this->options->thumb_path . "thumb" . $imagename;}elseif ($type == "png" || $type == "PNG"){ $img_source = imagecreatefrompng($this->path.$imagename); $oldWidth = imagesx($img_source); $oldHeight = imagesy($img_source); $newHeight = intval((doubleval($newWidth)/doubleval($oldWidth))*$oldHeight); $img_destination = imagecreate($newWidth,$newHeight); imagecopyresized($img_destination,$img_source,0,0,0,0,$newWidth,$newHeight,$oldWidth,$oldHeight); imagepng($img_destination,$this->options->thumb_path . "thumb" . $imagename); return $this->options->thumb_path . "thumb" . $imagename;}
  2. Goose

    dyanamic combo box

    If you're going to make a call to mysql every time the user changes something then use php. This means that the page will have to be reloaded every time.Your other option (if your database is very small) is to use php to load all your data into a javascript variable the first time the page is loaded. Then you won't need to reload the page every time 'cause you can use javascript to do all the work.To use the value of the select element just give the element a name (eg. <SELECT name="first_name" >) and then submit the form. You can then use "$_POST['first_name']" if you used the POST method or "$_GET['first_name']" if you used the GET method in your sql query. (eg. "SELECT * FROM students WHERE first_name = {$_POST['first_name']}")Hope this helps.
×
×
  • Create New...