Jump to content

Vyx

New Members
  • Posts

    4
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Vyx's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Sorry to bring this back up but my problem isn't actually solved :*( I used <td><a href="http://link.com"><?php include('scripts/randimg.php'); ?></a></td> This works beautifully save the fact that I can't insert height, width, and specifically border tags. I tried inserting them directly into the script file but it says Parse error: syntax error, unexpected T_LNUMBER, expecting ',' or ';' in /home/aenigma/public_html/vyx/scripts/randimg.php on line 63 I also tried using the suggestion posted by grimmier and thorpe but couldn't get either of these to work. Any ideas?
  2. Awesome, thanks for the help!
  3. Here is the php script (sorry, lots of comments for learning purposes): <? //Directory the images are stored relative to root. $imgdir = '/home/aenigma/public_html/vyx/media/images/header'; //Path to images folder $dirpath = '/media/images/header/'; //Create an array with the list of files as each value. //Keep in mind, the first two values listed for a directory //will always be: "." and ".." UNLESS you change the //sort order. $dirlist = scandir($imgdir); //Count the number of items in the array "dirlist" //Basically, count how many files are in the directory. //We subtract 1 from this because it counts the "0" value //in teh array as 1. $dircount = count($dirlist) - 1; //Get a random number between 2 and the size of the array. $randnum = mt_rand(2,$dircount); //When you create an array, every entry into the array //is assigned a value 0-128. When we create a random number //between 2 and the maximum number of values in the array, //we're essentially picking which value to call from teh array. //This next part uses our random value as the entry to call from //the array. $imgname = $dirpath . $dirlist[$randnum]; //Now we just tell php to show the image. echo "<img src='$imgname'></img>"; ?> Here is the HTML: <table width="600" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td><a href="http://link.com"><img src="<? include('scripts/randimg.php'); ?>" width="600" height="150" border="0"></a></td> </tr>
  4. Sorry for this silly question but I've just started using php for the 1st time. (today) I have a random image script that a friend put together to help me learn php. If I just insert it by itself it comes up fine. The problem is when trying to make the image that the script shows a link. ie. a link back to the homepage as this is a header image. What I have now is just the simple html tags: <a href "link"><img src=<? include('scripts/randimg.php'); ?>" width...></a> This however doesn't work Can someone tell me what I'm doing wrong? Thanks, Vyx
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.