Jump to content


  • Posts

  • Joined

  • Last visited

albridge's Achievements


Newbie (1/7)



  1. thanks men. was looking for a php solution but i guess this one would do for now. in fact it works quite fine and i'm somewhat impressed with the results. thanks men. really appreciate your response and solution.
  2. i am trying to build a membership site where members can select search criteria like male or female and age to view profiles of other members on the system. on the result page i want to dynamically generate thumbnail like immages (smaller images) from an uploaded image of each member. i have tried to do this with php gd function 'imagecopyresized' and while it does successfully resize the image, it appears to only do so for the first or last image cos all the outputted images on the search result page are the same. however, if only one member on the search result has uploaded a profile image then only that image is uploaded in the right position and correctly. i have written the imageresize script in a seperate file and inlclude it in a while loop as the query returns matching profiles. i do this so i can pass the unique id of each member to the include file with which it is supposed to get, resize and output the appropriate image of each member. been on this for two days now. would really appreciate some help. please take it slow with me cos i am still new to php. the code is shown below. <?php$query="select photo from testmember where id='".$rowdd['id']."'";$result=mysql_query($query);$row=mysql_fetch_array($result);// Crop dimensions.$width = 100;$height = 100;//if(!empty($row['photo'])){$imd=$row['photo']; // Set the path to the image to resize$input_image = $imd;// Get the size of the original image into an array$size = getimagesize( $input_image );// Prepare canvas$canvas = imagecreatetruecolor( $width, $height );// Create a new image in the memory from the file $cropped = imagecreatefromjpeg( $input_image );// Prepare image crop - center the crop on the image$newwidth = $size[0] / 2;$newheight = $size[1] / 2;$cropLeft = $size[0]/4; //( $newwidth/2 ) - ( $width/2 );$cropHeight = ( $newheight/2 ) - ( $height/2 );// Generate the cropped imageimagecopyresized( $canvas, $cropped, 0,0, $cropLeft, $cropHeight, ($size[0]/2), ($size[1]/2), $newwidth, $newheight );// Save the cropped image as cropped.jpgimagejpeg( $canvas, "cropped.jpg" );//$neewname="images/cropped.jpg";//copy("cropped.jpg","images/cropped.jpg");// Clear the memory of the tempory imagesecho "<img src='cropped.jpg'>";imagedestroy( $cropped );imagedestroy( $canvas );//}$cropped="";?> i try to make use of the output of the code above like this <td width="132" height="148" style="vertical-align:top "><?php if(!empty($rowdd['photo'])){ include('cropimage.php');} ?></td> the funny thing is that if i refresh the result page many times enough (like 20 or 30 time) the page sometimes displays the appropriate images in beside the right member. i dont get itplease someone kindly hook me up. if you have a better or easier way that i can easily understand cos like i said i am still new to this and most of this php stuff still sound like martian language to me so the easier to understand the better. thank again.
  3. just want to say thanks again for your help. took another look at the code and got to figure out the confusing areas. thanks again for all your help. thanks chibineku and justsomeguy for your help. really appreciate your contribution.
  4. first of all i really appreciate you taking time to try to make things clear to me. means a lot to me. however i would like to point out some other specific areas i want cleared out. first please could explain this part of the codeif ($hint=="") { $hint=$a[$i]; that piece of code looks like if $hint is same as an empty string then set it to an element of the array $a. i dont get that cause i think if $hint is empty then it should be empty. how come a value is assigned when $hint is empty.then i would like to get some clarification on the else part of the condition also } else { $hint=$hint." , ".$a[$i]; especially the part of $hint=$hint.","$a[$i]; thanks in for your help here.
  5. saw this example on the w3school site on creating an auto suggestion ajax/php form. it works perfect but i don't totally understand how it all works. would appreciate anyone who can do a bit more commenting on the code so i can get how it really works.the complete tutorial is found here the complete code is herei especially need clarification in the following part of the code especially the areas with $hint. just dont get that part <?php//lookup all hints from array if length of q>0if (strlen($q) > 0) { $hint=""; for($i=0; $i<count($a); $i++) { if (strtolower($q)==strtolower(substr($a[$i],0,strlen($q)))) { if ($hint=="") { $hint=$a[$i]; } else { $hint=$hint." , ".$a[$i]; } } } }// Set output to "no suggestion" if no hint were found// or to the correct valuesif ($hint == "") { $response="no suggestion"; }else { $response=$hint; }//output the responseecho $response;?>
  • Create New...