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 7 of 7
  1. #1
    New to the CF scene
    Join Date
    Mar 2003
    Location
    NYC, USA
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy Image link generator

    Hi everyone,
    I am trying to find a script where i can generate photo links. Below is an example of what i am looking for. Thank you for your time- your help is highly appreciated!




    The Generator


    the URL: http://www.domain.com/mypic001.jpg

    Repeated Source: http://www.domain.com/mypic
    Low range: 1
    High range: 10
    Leading zeros: 2
    Suffix: sfx
    File extention: jpg

    The results


  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    frankfurt, german banana republic
    Posts
    1,848
    Thanks
    0
    Thanked 0 Times in 0 Posts
    hmmh... looks like some kind of bulletin board code... you are not by chance trying to flood someone's forum, are you?

    Your problem is easily solved with a simple function that repeats a certain string a defined number of iterations:

    PHP Code:
    function generateImageLinks($url$suffix$extension$low$high) {
        for (
    $i $low$i <= $high$i++) {
            print 
    "[IMG]$url";
            print 
    str_pad($i3'0'STR_PAD_LEFT);
            print 
    $suffix;
            print 
    ".";
            print 
    $extension "[/IMG]\n";
        }
    }

    generateImageLinks('http://www.domain.com/mypic''sfx''jpg'110); 

  • #3
    New to the CF scene
    Join Date
    Mar 2003
    Location
    NYC, USA
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hiya Mordred

    Thanks for the supa quick reply!


    One problem with the code you made for me.. .
    I am a dreamweaver abuser, which means i dont know how to finish the codes or how to blend it in.

    May you please help me complate this?
    Much Thanks
    -FunLove

  • #4
    New to the CF scene
    Join Date
    Mar 2003
    Location
    NYC, USA
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I dont really know what im doing but im guessing its soemthing like this??


    ?>
    PHP Code:


    <?php
    /***************************************************************************



     function generateImageLinks($url, $suffix, $extension, $low, $high) {
        for ($i = $low; $i <= $high; $i++) {
            print "[IMG]$url";
            print str_pad($i, 3, '0', STR_PAD_LEFT);
            print $suffix;
            print ".";
            print $extension . "[/IMG]\n";
        }
    }

    generateImageLinks('http://www.domain.com/mypic', 'sfx', 'jpg', 1, 10);
    <body bgcolor="#FFFFFF" text="#000000">
    <form name="form1" action="">
      <input type="text" name="$url">
    </form>



    <form name="form1" action="">
      <input type="text" name="$low">
    </form>


    <form name="form1" action="">
      <input type="text" name="$high">
    </form>

    <form name="form2" method="post" action="">
      <input type="submit" name="Submit" value="Submit">
    </form>
    -FunLove

  • #5
    New to the CF scene
    Join Date
    Mar 2003
    Location
    NYC, USA
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    oh ok i got it now
    i see how it works.

    but what im also trying to do is to be able to change the $low, $high, $url, ext.. . in the text feild box.

    how im i able to do that?
    -FunLove

  • #6
    Senior Coder
    Join Date
    Jun 2002
    Location
    frankfurt, german banana republic
    Posts
    1,848
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Well, dreamweaver may be helpful tool for web designing, but it doesn't help you learning a programming language that much IMO. You'd be better served by using a simple text editor (of course you could use dreamweavers textedit mode for that) and a bunch of tutorials accompanied with the manual to learn PHP. This will be much more rewarding in the long term, because you gain the ability to control your code as you see fit.

    Anyway, I suppose your question should be rather phrased as "how do I pass variables that are created after my form submits into the function".
    First, you have to give your form a method, that's proper style and you know later in your code for which variables you have to check. If you decide that your form shall be submitted with the POST method, then all values of the form fields can be reached in the PHP script by the following syntax:

    PHP Code:
    $_POST['nameOfFormField'
    Of course you have replace the name of the form field to suit your needs. These variables can then be passed to the function as arguments, like

    PHP Code:
    generateImageLinks($_POST['url'], $_POST['suffix'], $_POST['extension'], $_POST['low'], $_POST['high']); 
    The above assumes you run a PHP version 4.1 or greater.

  • #7
    New to the CF scene
    Join Date
    Mar 2003
    Location
    NYC, USA
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank you very much for your help!
    MUAHHHH
    Sorry for the delay.
    -FunLove


  •  

    Posting Permissions

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