/    Sign up×
Community /Pin to ProfileBookmark

Random Urls out of txt ?

I am new, i have questions, and i want answers ^^
Hope you can help me, ok here is my problem:

I have a site, and i want to have random pics with link as a gallery, but no pic should be dublicated, so -> its would be great if i just could write urls in a txt file, and javascrip splits this img+url links and load them into my page, checking that no pic is two times on my page.

Please tell me if this is possible

to post a comment
JavaScript

8 Comments(s)

Copy linkTweet thisAlerts:
@Bootsman123Aug 02.2003 — I don't know if you can read text files with Javascript. Don't think so actually. But it can be easily done with PHP.
Copy linkTweet thisAlerts:
@BigBobauthorAug 02.2003 — can you please tell me how i can do that or give me a link to a php script that can do that stuff ?
Copy linkTweet thisAlerts:
@Bootsman123Aug 02.2003 — There are several ways of doing it with an extra file.

[code=php]
resource.php
<?php
$img_array = array ("img1.gif", "img2.gif", "img3.gif", "img4.gif", "img5.gif");
$url_array = array ("url1", "url2", "url3", "url4", "url5");
?>
random_image.php
<?php
@include ('resource.php');
/* Rest of the script. */
?>
[/code]

For the random script I suggest checking:

http://www.php.net/array-rand

If you want to use a text-file, I suggest checking this:

http://www.php.net/fopen
Copy linkTweet thisAlerts:
@BigBobauthorAug 02.2003 — thx, but thats not exactly what i want, i will make an other example:

Url.txt :
-----


<a href="http://url1.de"><img src="http://img1.jpg"></a>

<a href="http://url2.de"><img src="http://img2.jpg"></a>

<a href="http://url3.de"><img src="http://img3.jpg"></a>

<a href="http://url4.de"><img src="http://img4.jpg"></a>

<a href="http://url5.de"><img src="http://img5.jpg"></a>

<a href="http://url6.de"><img src="http://img6.jpg"></a>
-----



Than each Url Tags need to be splited and kicked into and aray variable, for example on the main page :

Picture-links: 'var[1]' , 'var[2]' , 'var[3]', 'var[4]', 'var[5]', 'var[6]'

And i want to load this url tags in random position in my page also no picture link should be dublicated. Is that possible ?
Copy linkTweet thisAlerts:
@Bootsman123Aug 02.2003 — I still don't get it completely. What do you mean by "Than each Url Tags need to be splited and kicked into and aray variable"?

[code=php]
<?php
$input_array = file ("Url.txt");
/* $array is an array, containing 6 items */

$number_img = 3;

$rand_img = array_rand ($input_array, $number_img);

for ($i = 0; $i < count ($rand_img); $i++)
{
echo $rand_img[$i];
}
?>
[/code]
Copy linkTweet thisAlerts:
@BigBobauthorAug 02.2003 — ok i try to explain ^^

60 img links in a txt file, like this

<a href="http://url1.de"><img src="http://img1.jpg"></a>

<a href="http://url2.de"><img src="http://img2.jpg"></a>

<a href="http://url3.de"><img src="http://img3.jpg"></a>

<a href="http://url4.de"><img src="http://img4.jpg"></a>

<a href="http://url5.de"><img src="http://img5.jpg"></a>

<a href="http://url6.de"><img src="http://img6.jpg"></a>

etc...

The main site shows 30 of 60 img links loaded from the txt randomly, so i have 30 pictures with a link on it

So later i can easy paste my urls in the txt file and the script automaticly list them randomly in the main page, now understand ?
Copy linkTweet thisAlerts:
@Bootsman123Aug 02.2003 — No, but you can set $number_img to 30, to get 30 random images + link. And if you want to place the images random on the page, check this topic:

http://forums.webdeveloper.com/showthread.php?s=&threadid=14486

And could you provide me with some code of what you've already done, because you can't expect me (or others) to do all the coding for you.
Copy linkTweet thisAlerts:
@BigBobauthorAug 02.2003 — my code is in javascript and not loaded out of a txt
×

Success!

Help @BigBob spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.2,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...