#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2002
    Posts
    7
    Rep Power
    0

    Angry PHP / Javascript Pop up Window - HELP!


    I have been working with a real estate listing PHP/mySQL program and have everything configured and working great, but I want to a chnage -

    I am trying to set a way to have a thumbnail of a pic clicked on and a Javascript to pop open a window with the pic in, just large enough for the pic.

    I have it done, but can not dynamically generate the width and height of the image for the javascript to execute.

    Here is the code that I have right now...

    <a href=\"javascriptisplayImage('image.php?Id=$image_row[id_files]','280','395')\">
    <img src='image.php?Id=$image_row[id_files]' border=1 width=100 alt=\"Photo\"></a>

    It works great, but I want to dynamically generate the height and width, which are 280 and 395 respectively.

    I know there is an

    int ImageSX (int imagename)
    int ImageSy (int imagename)

    functions, but I have no idea how to incorporate them to generate the numbers I need.

    I trued this -

    <a href=\"javascriptisplayImage('image.php?Id=$image_row[id_files]','int ImageSX (int 'image.php?Id=$image_row[id_files])','395')\">

    just to see what would happen and the window opened fine with the width )395) being fine, but the height was the full height of a normal window.

    This will finish off the program for me and let me go live, so if anyone has any ideas, please let me know.

    Thanks!

    David Young
  2. #2
  3. No Profile Picture
    Do you like PHP like ME?
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2001
    Location
    St. George, Utah, of the USA
    Posts
    67
    Rep Power
    13
    hmm... so do you want the dynamically generate the width/height of the image or the window? And could you strip the PHP away and juts put a fake image there so I can look at it with Javascript in a way that my jscript book incorporates it? Or if not, display more of the code that you wokring with.
    You know your a web programmer when you see a '$' and think of PHP rather than money.
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2002
    Posts
    7
    Rep Power
    0

    Tansk for replying...


    I am trying to generate the following


    <a href=\"javascriptisplayImage('image.php?Id=$image_row[id_files]','280','395')\">
    <img src='image.php?Id=$image_row[id_files]' border=1 width=100 alt=\"Photo\"></a>

    where the 280 and 395 would dynamically change to the image height and width... the only problem after that is that

    ther needs to be space around the image as the Javascript calls for

    the image height + 30
    the image width + 20

    so the image above would be 250 in height and 375 in width

    do you have ICQ or MSN Messenger.. if so

    my ICQ is 98302248
    MSN - go_huskers_go@hotmail.com

    Thanks...

    Here is where you can see the code -

    http://homes.markation.com/propview.php?view=2

    right now the window height and width are hard coded at 280 and 395.
    Last edited by dmyoungmba; April 6th, 2002 at 06:41 PM.
  6. #4
  7. Potato with a mask
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2002
    Location
    Sarajevo- BiH
    Posts
    25
    Rep Power
    0

    Hot so hard but...


    I had the same problem and this is what i figured out.

    You must upload image trough php (http, or ftp it dosent matter).

    Code:
    $image_hw = GetImageSize($probe);
    $image_width = $image_hw[0];
    $image_height = $image_hw[1];
    when the name and location of the image uploaded are placed in the database it is not hard to place widht and height too.

    If you are not using database then try writing values in the file.
  8. #5
  9. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2002
    Posts
    7
    Rep Power
    0

    Thanks.... but?


    Thanks for the help, but I what do I do with that code then?

    Where would it go?

    This is what I tried and it gave me a mean error -

    {
    $image_hw = GetImageSize($probe);
    $image_width = $image_hw[0];
    $image_height = $image_hw[1];


    print "<td valign=top align=center width=115><a href=\"javascriptisplayImage('image.php?Id=$image_row[id_files]','$image_height','$image_width')\"><img
    src='image.php?Id=$image_row[id_files]' border=1 width=100 alt=\"Photo\"></a><br></td>";
    $count++;
    }

    All I need is the height and width of the image to be returned so that it can go into the Javascript statement, which will then generate a pop up window if click on.

    Thanks and let me know what you think.

    - David Young
  10. #6
  11. Potato with a mask
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2002
    Location
    Sarajevo- BiH
    Posts
    25
    Rep Power
    0

    Ok here is the complete code


    Code:
    <form action="<?php $PHP_SELF ?>">
            <input type="file" name="image" class="unos">
            <input type="submit" value="Upload" class="button">
    </form>
             <?php
    		
      if (isset($image)) :
    
    $image_hw = GetImageSize($image);
    $image_width = $image_hw[0];
    $image_height = $image_hw[1];
    $imgorig = $image_width;
    
        if ( isset($HTTP_COOKIE_VARS["image"]) ||
             isset($HTTP_POST_VARS  ["image"]) ||
             isset($HTTP_GET_VARS   ["image"])         
           ) die(mysql_error());
    	   
    
    if ($image_type == "image/pjpeg" or $image_type == "image/gif")
    	   {
    	   printf("File <font color='#FF0000'>$image_name</font> is uploaded on server, location: <font color='#FF0000'>../YOUR_PAHT_TO_IMG_DIR/$image_name</font><br>\n",
          $image_name); 
        printf("&nbsp; FIle size<font color='#FF0000'>%s</font> bits i type: <font color='#FF0000'>%s</font>  <br>
    	&nbsp; Widht:<font color='#FF0000'>%s</font> i Height: <font color='#FF0000'>%s</font>.<br>\n",
          $image_size, $image_type, $image_width, $image_height); 
    
    
    $abspath = "absolute_path_to_image_dir"; //Absolute path to where images are uploaded. No trailing slash
    $sizelim = "no"; //Do you want size limit, yes or no
    $size = "51200"; //What do you want size limited to be if there is one
    
    $ftp_host = "your_ftp_host";
    $ftp_port = 21;
    
    $ftp_user = "username";
    $ftp_pass = "password";
    
    $ftp = ftp_connect($ftp_host, $ftp_port); 
    
    $login = ftp_login($ftp, $ftp_user, $ftp_pass); 
    
    // check connection
    if ((!$ftp) || (!$login))
    { 
    	echo "&nbsp; Ftp conection failed!<br>";
    	echo "&nbsp; Connection should have been made to $ftp_host<br>"; 
    	die; 
    }
    else
    {
    	echo "Connected to $ftp_host<br>";
    }
    
    // upload the file
    $upload = ftp_put($ftp, "$abspath/$image_name", $image, FTP_BINARY); 
    
    // check upload status
    if (!$upload) { 
            die ("Ftp upload failed!<br>");
        } else {
            echo "Upload sucessful. File: $image_name<br>";
        }
    
    // close the FTP stream 
    ftp_quit($ftp); 
    
    
    $query = "INSERT INTO `table` (`id`, `widht`, `height`, `path`, `name`) 
     VALUES  ('', '$image_width', '$image_height', '../YOUR_IMG_DIR/$image_name')";
    mysql_query($query) or die
    (mysql_error());
    	  }
    
      endif; 
        
     ?>
    Ok check this out, this is the complete code for uploading and storing info in database, late you just get data from mySql database and use it in your output file.
  12. #7
  13. Potato with a mask
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2002
    Location
    Sarajevo- BiH
    Posts
    25
    Rep Power
    0

    If this is not what you need...


    ..becouse you will probably have to change a large bit of your aploication trere are some javascripts that might help.

    Try searching for widht on http://javascript.internet.com/
  14. #8
  15. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2002
    Posts
    7
    Rep Power
    0

    Thanks.... but?


    Thanks again...

    I threw it in there, so it looks like this

    {

    $image_hw = GetImageSize($image);
    $image_width = $image_hw[0];
    $image_height = $image_hw[1];
    $imgorig = $image_width;

    print "<td valign=top align=center width=115><a
    href=\"javascriptisplayImage('image.php?Id=$image_row[id_files]','$image_height','395')\"><img
    src='image.php?Id=$image_row[id_files]' border=1 width=100 alt=\"Photo\"></a><br></td>";
    $count++;

    }

    and the resulting page via the web looks like this

    http://homes.markation.com/propview.php

    AHHHHHHHHHHHHHHH...... So close...
  16. #9
  17. Potato with a mask
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2002
    Location
    Sarajevo- BiH
    Posts
    25
    Rep Power
    0

    Ok you shoul read carefuly


    1. This code is for determining size of the uploaded image

    2. You should place it in the file in which is the script for upload

    3. You should make 2 new row called widht & height

    4. You shoul use data from those rows in your output page

    This should be clear now() i think.
  18. #10
  19. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2002
    Posts
    7
    Rep Power
    0

    Thanks...


    I got it...

    Thanks...
  20. #11
  21. Potato with a mask
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2002
    Location
    Sarajevo- BiH
    Posts
    25
    Rep Power
    0

    Cool OK


    Finaly, it was 5 am and i was tired and begining to get nevous becouse you are actualy not readin what i was posting.

    I am glad that i could help.

    Bye

IMN logo majestic logo threadwatch logo seochat tools logo