Issue with php coding.

Zoekban

Registered Member
Joined
Apr 23, 2013
Messages
63
Reaction score
15
Good day!
I'm using 2 scripts.
I use it through a plugin for php n wordpress.


1-
$minutes = date('i');
if($minutes<=15) {
$total = "2";
}elseif($minutes<=30){
$total = "2";
}
$file_type = ".jpg";
$image_folder = "image source";
$start = "1";




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




$image_name = $random . $file_type;




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




2-


$total = "2";
$file_type = ".jpg";
$image_folder = "image source";
$start = "1";


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


$image_name = $random . $file_type;


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




And the problem I'm experiencing is that the images that the script should randomly display, are being kinda mixing with each other, Can you please check what the problem is with? because for example, If i try to make a table with those script, the table is getting mixed up and I can't work it out.
Thanks from advanced.
 
mt_rand function uses integers and your variables $total and $start are strings. You should remove the quotation marks. They should look like this:

$total = 2;
$start = 1;
 
Back
Top