Archive

Archive for the ‘HTML Tips’ Category

Random image

August 15, 2008 Adeel Ansari Leave a comment

Random image

Displays a random image on a web page. Images are selected from a folder of your choice.

<?php

/*
* Name your images 1.jpg, 2.jpg etc.
*
* Add this line to your page where you want the images to
* appear: <?php include “randomimage.php”; ?>
*/

// Change this to the total number of images in the folder
$total = “11″;

// Change to the type of files to use eg. .jpg or .gif
$file_type = “.jpg”;

// Change to the location of the folder containing the images
$image_folder = “images/random”;

// You do not need to edit below this line

$start = “1″;

$random = mt_rand($start, $total);

$image_name = $random . $file_type;

echo “<img src=\”$image_folder/$image_name\” alt=\”$image_name\” />”;

?>

Categories: HTML Tips, PHP Tips Tags:

PHP: Random Quote

August 15, 2008 Adeel Ansari Leave a comment

PHP: Random Quote

Make a file called quotes.txt

Put each quote on it’s on line.

Here’s a script:

<?
$r_array=file(‘quotes.txt’);
shuffle($r_array);
echo $mQuotePath[0];
echo $r_array[0];
?>

Categories: HTML Tips, PHP Tips

File Browse without button

August 15, 2008 Adeel Ansari Leave a comment

File Browse without button
<html>
<head>
<title>File Upload Example</title>
<script language=”JavaScript” type=”text/javascript”>
function HandleFileButtonClick()
{
document.frmUpload.myFile.click();
document.frmUpload.txtFakeText.value = document.frmUpload.myFile.value;
}
</script>
</head>
<body>
<form name=”frmUpload”>
<input type=”file” name=”myFile” style=”display: none”>
<input type=”text” name=”txtFakeText” readonly=”true”>
<a href=”javascript:HandleFileButtonClick();”>Attach</a>
</form>
</body>
</html>

Move Window

August 15, 2008 Adeel Ansari Leave a comment

Move Window
<meta http-equiv=”refresh” content=”5;URL=windowmove.html”>
<script>
<!–//
var mx=10
var my=10

function movewindow(n)
{
if (window.top.moveBy)
{
for (i = 10; i > 0; i–)
{
for (j = n; j > 0; j–)
{
window.top.moveBy(0,i);
window.top.moveBy(i,0);
window.top.moveBy(0,-i);
window.top.moveBy(-i,0);
}
}
}
}

–>
</script>
</HEAD>
<BODY onload=”movewindow(10);”>

Categories: HTML Tips Tags: