...

View Full Version : Image link generator



funlove818
03-21-2003, 10:00 PM
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
http://www.70megs.com/funlove/images/repeat.gif

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

http://www.70megs.com/funlove/images/result.gif

mordred
03-21-2003, 11:52 PM
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:



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

generateImageLinks('http://www.domain.com/mypic', 'sfx', 'jpg', 1, 10);

funlove818
03-22-2003, 12:04 AM
Hiya Mordred

Thanks for the supa quick reply!
:thumbsup:

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
:o

funlove818
03-22-2003, 12:16 AM
I dont really know what im doing but im guessing its soemthing like this??


?>



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



function generateImageLinks($url, $suffix, $extension, $low, $high) {
for ($i = $low; $i <= $high; $i++) {
print "$url";
print str_pad($i, 3, '0', STR_PAD_LEFT);
print $suffix;
print ".";
print $extension . "\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>

funlove818
03-22-2003, 12:34 AM
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?

mordred
03-22-2003, 01:17 PM
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:



$_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



generateImageLinks($_POST['url'], $_POST['suffix'], $_POST['extension'], $_POST['low'], $_POST['high']);


The above assumes you run a PHP version 4.1 or greater.

funlove818
04-08-2003, 01:30 PM
Thank you very much for your help! :)
MUAHHHH
Sorry for the delay.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum