Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

php script for rand between 2 images

Posted on 2006-11-09
4
Medium Priority
?
327 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 19

Accepted Solution

by:
VoteyDisciple earned 1000 total points
ID: 17906742

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

Assisted Solution

by:Eduardo_Pinto
Eduardo_Pinto earned 1000 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

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

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.
This is about my first experience with programming Arduino.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
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…

636 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