Jump to content

php help


tarnold4

Recommended Posts

Im very new to php, I wanted to see if anyone could help me with the following. I have to take a function, along with the count function, to randomly select one of the array values. Use the return keyword to return this value and end the function. The value returned should be one of the provided file names.

Link to comment
Share on other sites


This is what i came up with, the whole thing is supposed to randomly show a different image everytime the webpage is loaded.
When i test it, all it does is pretty much shows the title, but no image

<html>
<head>
<title>JFQ Turnings</title>
</head>
<body bgcolor="#ffffff" text="#000000">
<img src="jfqturnings.gif" alt="JFQ Turnings, coming soon." width="864" height="100">
<br /><img src="<?php echo getRandomImage(); ?>" alt="" width="864" height="567">
<?php
echo getRandomImage();
function getRandomImage()
{
$images = array("candlestick.jpg", "rollingpin.jpg", "table.jpg", "table2.jpg");
$random = rand(0, 3);
return $images[$random];
}
?>
</body>
</html>
Link to comment
Share on other sites

I thought that to but, its fine.

 

Are you seeing a broken image? If so, did you go into your browser window's source code to make sure the file name is coming through? If the name is fine, the problem is most likely due to the path being incorrect...or maybe the file names don't match the ones listed in the array.

Link to comment
Share on other sites

Are you seeing a broken image? If so, did you go into your browser window's source code to make sure the file name is coming through? If the name is fine, the problem is most likely due to the path being incorrect...or maybe the file names don't match the ones listed in the array.

wait a second ... if he didnt save the img in the same folder isnt showing a broken image something normal ? maybe upload it and put it url instad of "picname.jpg" part .. it may work.

Here its css/html more then PHP :)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.