Solved

php script for rand between 2 images

Posted on 2006-11-09
4
309 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
thread-safe code in c++ 2 72
add text to end of existing text in file 16 62
VBA color chart bars 12 66
noX challenge 17 76
Here we come across an interesting topic of coding guidelines while designing automation test scripts. The scope of this article will not be limited to QTP but to an overall extent of using VB Scripting for automation projects. Introduction Now…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
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…

757 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now