Random photo on site

©

©®

Every week I do a bulletin of news for our intranet and add a new
picture and delete the one that was there. Ideally I would like to have
a directory of pictures and then let it sequentially go through the list
and change it each time someone loads/refreshes a page.

How do I do this. (I might have about 100 pictures). Am using DWeaver MX
and it is a simple html intranet. Many people who are on the intranet
have old computers so it would be nice to take their situation into
account if at all possible!
Thanks
 
T

Toby A Inkster

Ideally I would like to have
a directory of pictures and then let it sequentially go through the list
and change it each time someone loads/refreshes a page.

If you are using Apache 2, then look into mod_variety.

From the package description: "mod_variety is an Apache 2.x module that
will serve a random file from the requested directory. It is useful for
serving random images or completely random sites."
 
T

Toby A Inkster

<smip>

Er... how do I know that?

By looking at the HTTP headers. But if you don't already know this, you're
probably not in the position to install mod_variety.
All I do is change html file and upload using FTP program.
Is there a script I can use?

I'm sure there are several decent PHP/CGI scripts for random images. Find
out what server-side scripting languages your server supports.
 
F

floortje

©® said:
Every week I do a bulletin of news for our intranet and add a new
picture and delete the one that was there. Ideally I would like to have
a directory of pictures and then let it sequentially go through the list
and change it each time someone loads/refreshes a page.

How do I do this. (I might have about 100 pictures). Am using DWeaver MX
and it is a simple html intranet. Many people who are on the intranet
have old computers so it would be nice to take their situation into
account if at all possible!
Thanks

easiest way would be to write a small upload script and insert the names
into a database.
im assuming u got a .htraccess protected zone somwhere where unly u can come
out and play

databasename foto
field varchar 50 name foto
dont forget to chmod ur upload folder

<?php
include("db.php"); // contains mysql connection + error checking

if ($_POST["action"]=="new"){
$destination="../foto"; //whatever
if ($foto <> "none"){copy($foto,$destination."/".$foto_name);}else{
echo "er is geen foto ontvangen, ga terug en voer een foto in";exit;}
mysql_query("INSERT INTO foto
(`foto`)
VALUES ('$foto_name')
")or die("Query1 failed");
header("Location: http://thispage.com"); // dont like post data hanging
around
exit;
}else {?>
<form action="index.php" method="post" enctype="multipart/form-data"
name="form1">
<input name="action" type="hidden" id="action" value="new">
<p class="standaard">Foto<br>
<input type="file" name="foto">
</p>
<input type="submit" name="Submit" value="verstuur">
</form>
<?php } ?>

and to call the pic inser this somewhere
<?php
include("db.php"); // contains mysql connection + error checking
$query = mysql_query("SELECT foto FROM foto ORDER BY RAND() limit 1;");
$row = mysql_fetch_array($query);
echo "<img src=\"$row[foto]\" width=\"200\"><html>";
?>
 
F

floortje

floortje said:
©® said:
Every week I do a bulletin of news for our intranet and add a new
picture and delete the one that was there. Ideally I would like to have
a directory of pictures and then let it sequentially go through the list
and change it each time someone loads/refreshes a page.

How do I do this. (I might have about 100 pictures). Am using DWeaver MX
and it is a simple html intranet. Many people who are on the intranet
have old computers so it would be nice to take their situation into
account if at all possible!
Thanks

easiest way would be to write a small upload script and insert the names
into a database.
im assuming u got a .htraccess protected zone somwhere where unly u can come
out and play

databasename foto
field varchar 50 name foto
dont forget to chmod ur upload folder

<?php
include("db.php"); // contains mysql connection + error checking

if ($_POST["action"]=="new"){
$destination="../foto"; //whatever
if ($foto <> "none"){copy($foto,$destination."/".$foto_name);}else{
echo "er is geen foto ontvangen, ga terug en voer een foto in";exit;}
mysql_query("INSERT INTO foto
(`foto`)
VALUES ('$foto_name')
")or die("Query1 failed");
header("Location: http://thispage.com"); // dont like post data hanging
around
exit;
}else {?>
<form action="index.php" method="post" enctype="multipart/form-data"
name="form1">
<input name="action" type="hidden" id="action" value="new">
<p class="standaard">Foto<br>
<input type="file" name="foto">
</p>
<input type="submit" name="Submit" value="verstuur">
</form>
<?php } ?>

and to call the pic inser this somewhere
<?php
include("db.php"); // contains mysql connection + error checking
$query = mysql_query("SELECT foto FROM foto ORDER BY RAND() limit 1;");
$row = mysql_fetch_array($query);
echo "<img src=\"$row[foto]\" width=\"200\"><html>";
?>
Oops thought I was posting in alt.php ... sry
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top