php random images help... please...!!!?

tikki

New member
This is my code for a static chessboard. Now i want to randomize the way these images show up..!!!
how can i do that and have all the pieces display..??
If you can't do that..can you at least tell me how to put a pop up text on each of the images that come up?...try this in a browser..it will be much clear as to what i am saying..!!!
Thank You..!!

Code:-
<html>
<head>
<title> Chessboard </title>
<link href="chess.css" rel="stylesheet" type="text/css" />
</head>
<body>

<div align="center">
<?php

$images = array(
array(
"rook1" => "<img src = \"8a.png\" >",
"knight1" => "<img src = \"8b.png\" >",
"bishop1" => "<img src = \"8c.png\" >",
"queen" => "<img src = \"8d.png\" >",
"king" => "<img src = \"8e.png\" >",
"bishop2" => "<img src = \"8f.png\" >",
"knight2" => "<img src = \"8g.png\" >",
"rook2" => "<img src = \"8h.png\" >"
),
array(
"pawn1" => "<img src = \"7a.png\" >",
"pawn2" => "<img src = \"7b.png\" >",
"pawn3" => "<img src = \"7a.png\" >",
"pawn4" => "<img src = \"7b.png\" >",
"pawn5" => "<img src = \"7a.png\" >",
"pawn6" => "<img src = \"7b.png\" >",
"pawn7" => "<img src = \"7a.png\" >",
"pawn8" => "<img src = \"7b.png\" >"
),
array(
"empty1" => "<img src = \"6a.png\" >",
"empty2" => "<img src = \"6b.png\" >",
"empty3" => "<img src = \"6a.png\" >",
"empty4" => "<img src = \"6b.png\" >",
"empty5" => "<img src = \"6a.png\" >",
"empty6" => "<img src = \"6b.png\" >",
"empty7" => "<img src = \"6a.png\" >",
"empty8" => "<img src = \"6b.png\" >"
),
array(
"empty1" => "<img src = \"6b.png\" >",
"empty2" => "<img src = \"6a.png\" >",
"empty3" => "<img src = \"6b.png\" >",
"empty4" => "<img src = \"6a.png\" >",
"empty5" => "<img src = \"6b.png\" >",
"empty6" => "<img src = \"6a.png\" >",
"empty7" => "<img src = \"6b.png\" >",
"empty8" => "<img src = \"6a.png\" >"
),
array(
"empty1" => "<img src = \"6a.png\" >",
"empty2" => "<img src = \"6b.png\" >",
"empty3" => "<img src = \"6a.png\" >",
"empty4" => "<img src = \"6b.png\" >",
"empty5" => "<img src = \"6a.png\" >",
"empty6" => "<img src = \"6b.png\" >",
"empty7" => "<img src = \"6a.png\" >",
"empty8" => "<img src = \"6b.png\" >"
),
array(
"empty1" => "<img src = \"6b.png\" >",
"empty2" => "<img src = \"6a.png\" >",
"empty3" => "<img src = \"6b.png\" >",
"empty4" => "<img src = \"6a.png\" >",
"empty5" => "<img src = \"6b.png\" >",
"empty6" => "<img src = \"6a.png\" >",
"empty7" => "<img src = \"6b.png\" >",
"empty8" => "<img src = \"6a.png\" >"
),
array(
"pawn1" => "<img src = \"2a.png\" >",
"pawn2" => "<img src = \"2b.png\" >",
"pawn3" => "<img src = \"2a.png\" >",
"pawn4" => "<img src = \"2b.png\" >",
"pawn5" => "<img src = \"2a.png\" >",
"pawn6" => "<img src = \"2b.png\" >",
"pawn7" => "<img src = \"2a.png\" >",
"pawn8" => "<img src = \"2b.png\" >"
),
array(
"rook1" => "<img src = \"1a.png\" >",
"knight1" => "<img src = \"1b.png\" >",
"bishop1" => "<img src = \"1c.png\" >",
"queen" => "<img src = \"1d.png\" >",
"king" => "<img src = \"1e.png\" >",
"bishop2" => "<img src = \"1f.png\" >",
"knight2" => "<img src = \"1g.png\" >",
"rook2" => "<img src = \"1h.png\" >"
)
);

$image = $images[ rand(0,(count($images)-1)) ];

foreach ($images as $individual)
{
echo "<br>";
foreach ($individual as $key => $value)
{
echo $value;
}// end 1st foreach

}// end 2nd foreach

?>
</div>

</body>
</html>
 
Back
Top