Solved

php script for rand between 2 images

Posted on 2006-11-09
4
319 Views
Last Modified: 2010-04-16
i need an php script that "rands" between 2 images
main ideea ... i have 1.jpg and 2.jpg .. and at every refresh i want them changed
0
Comment
Question by:rares_dumitrescu
4 Comments
 
LVL 19

Accepted Solution

by:
VoteyDisciple earned 250 total points
ID: 17906742

<img src="<?= rand(1, 2) ?>.jpg" alt="A Random Image" />
0
 

Assisted Solution

by:Eduardo_Pinto
Eduardo_Pinto earned 250 total points
ID: 17908061
<?php
session_start();

if ( isset($_SESSION[rand]) ){
 if ( $_SESSION[rand] == 1 ){
  $_SESSION[rand] = 2;
 }
 else{
  $_SESSION[rand] = 1;
 }
}
else{
   $_SESSION[rand] = 1;
}
?>

<img src="<?= $_SESSION[rand] ?>.jpg" />
 
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question