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
https://forums.phpfreaks.com/topic/294610-php-help/
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
https://forums.phpfreaks.com/topic/294610-php-help/#findComment-1505944
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
https://forums.phpfreaks.com/topic/294610-php-help/#findComment-1505961
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
https://forums.phpfreaks.com/topic/294610-php-help/#findComment-1506016
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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