Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2

Thread: php issue

  1. #1
    Regular Coder
    Join Date
    Sep 2006
    Posts
    216
    Thanks
    9
    Thanked 0 Times in 0 Posts

    php issue

    Hello,

    bit of an odd question, as this may be more javascript im not sure. I have a simple drop down box containing several values. Ideally i would like to select a value without using a button (with an onchange event) and use that value in an sql query. I have had a go myself below. Any help would be appreciated as I end up having to convert a javascript variable to php which cannot be done easily. Is there anyway to do this not using javascript and purely php??

    thanks

    Code:
    <html>
    <head>
    <script language=JavaScript>
    var TestVar
    function show(form) 
    {
        TestVar = form.clubs.value;
        alert(TestVar);
    
    var fred="<?php=$fred?>";
    }
    </script>
    
    </head>
    <body>
    <form name"myform">
    <select name=clubs onChange="show(this.form)">
    <option value=select selected="selected">- Select -</option>
    <option value=break>---------------------</option>
    <option value=<?php $variable = goalkeepers?> >Goal Keepers</option>
    <option value=<?php $variable = defenders?> > Defenders</option>"
    <option value=midfielders>Midfielders</option>
    <option value=strikers>Strikers</option>
    <option value=break2>---------------------</option>
    </select>
    </form>
    </script>
    <?php
    echo $variable;
    ?>
    </body>
    </html>

  • #2
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,538
    Thanks
    8
    Thanked 1,093 Times in 1,084 Posts
    I just had this type of issue with someone else.

    See this example page:
    http://www.catpin.com/grillz

    Now, in that example, I'm using another PHP script to re-size the image
    using GD image library. In your case, the PHP script that is called would
    take care of any MySQL stuff you need to do.

    For any others that are interested in the image resize portion,
    here's that script:

    PHP Code:
    <?php
    // The file
    $filename $_REQUEST['photo'];
    $wid=135;
    $hei=135;

    // Content type
    header('Content-type: image/jpeg');
    header('Content-length: '.filesize($filename));

    // Get new dimensions
    list($width$height) = getimagesize($filename);
    $new_width $wid;
    $new_height $hei;

    // Resample
    $image_p imagecreatetruecolor($new_width$new_height);
    $image imagecreatefromjpeg($filename);
    imagecopyresampled($image_p$image0000$new_width$new_height$width$height);

    // Output
    imagejpeg($image_pnull100);
    ?>


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •