You are here: Re: Random Thumbnail Script « All PHP « IT news, forums, messages
Re: Random Thumbnail Script

Posted by Steve on 03/03/07 17:04

"Shaffer" <gnrhapr@gmail.com> wrote in message
news:1172912253.921308.309240@z35g2000cwz.googlegroups.com...
| Hello,
| you can also use MySQL for this, which is probably better for you,
| since you might not want to handle so many arrays.
|
| * This is not a raw MySQL command, just the structure of the table for
| YOU to make on your own, using a manual, perhaps. :P
|
| 1) Create the thimbnails table:
| table thumbnails: id, alt, src, name, sub ;
| If you are not sure about creating the table, then I will show you how
| to.
|
| 2) Then, back in php, fetch a query and load the results onto an
| array, as shimmyshack, basically.
|
| $result = mysql_query(/* please */"SELECT id AS ID,alt AS ALT,src AS
| SRC,name AS NAME, sub AS SUB FROM thumbnails");
| while($row = mysql_fetch_array($result)) {
| if($row[SUB] == 0) {
| $thumbs[$row[ID]] = ("<img alt='$row[ALT]' src='$row[SRC]'
| name='$row[NAME]'/>" => "main");
| }
| elseif($row[SUB] == 1) {
| $thumbs[$row[ID]]
| }
| elseif($row[SUB] == 2) {
|
| }
| }
|
| Dunno, it's un-finished, bugged, and it's way too annoying to continue
| with it...
| I really don't know how the heck you came-up with it, and why in the
| form you have suggested.
| If you still insist that all you wanted is a pre-made script then
| please read the following.
| a) GO TO HELL, I HAD TO GET MY MOMMY UPSET FOR MAKING THIS, SINCE SHE
| MADE LUNCH.
| b) GO TO HELL, WHY DID YOU POST IT ON GOOGLE GROUPS AND WHY DIDN'T YOU
| MENTION THAT ALL YOU WANTED IS A SCRIPT BEFORE SHIIMMYSHACK HAS POSTED
| LIKE 200 LINES OF POST!
| c) Anyways, Steve: hear, hear!!

lol. actually, roflmfao! holy cow, i knew my response was a little
hash...but wow! ;^)

i suppose you and i have both seen enough of these kinds of posts to know
that the op is winking as he types, 'i really just need a pointer here and
there because i'm so new'. i think the giveaway is that it is obvious, to me
anyway, they want access to the author of the 'example' so there is less for
them to do when they find the *script* doesn't work. why is reading, trial,
and error such an afront to people? i mean, we aren't making stuff with an
enigma machine they have to crack to understand. christ, how hard would this
be to imagine and then look for the functions in the manual:

(assumes all images in same dir)

build an array of file names in a directory
find/use function to generate a random number
access an image from the array using the random number
output html image tag using source path to image

that's 5 minutes worth of reading, right? it translates to:

$path = /* your image server path here */;
$images = array();
$directory = opendir($path);
while (($fileName = readdir($directory)) !== false)
{
if ($fileName == '.' || $fileName == '..'){ continue; }
if (!is_file($path. $fileName)){ continue; }
$images[] = $fileName;
}
closedir($directory);
if (!is_array($images)){ $images = array(); }
$index = rand(0, count($images) - 1);
$src = /* your image http path here */;
echo '<img alt="RTFM" src="' . $src . urlencode($images[$index]) . '">';

that'd be another 5 minutes. and hey, with SOME imagination, you could
create an array of image paths, get a random image from each using the
above, and then randomly choose an image from the paths. but i
digress...numbnuts' eyes and mind are sufficiently boggled by now.

cheers.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация