Jump to content

Randomize


hcdarkmage

Recommended Posts

You would think this would be easy.  I have a problem getting my variables to insert into the HTML page that requests them.

I am trying to make 9 "dealers" randomize into 6 "slots" and take another 5 "dealers" to randomize into 2 "slots".  The output should look like this: http://wilsonelectronics.com/Dealer.php (the BUY NOW section).

 

This is the code I am using (with comments to explain):

<?php

// BUY NOW! Dealers. Create the Function
function BuyNow($dealer, $web, $site, $rank){

// Define the variables $dealer, $web, $site and $rank	
	$New[] = BuyNow('dealer1', 'web1', 'http://www.site1.com', '1');
	$New[] = BuyNow('dealer2', 'web2', 'http://www.site2.com', '1');
	$New[] = BuyNow('dealer3', 'web3', 'http://www.site3.com', '1');
	$New[] = BuyNow('dealer4', 'web4', 'http://www.site4.com', '1');
	$New[] = BuyNow('dealer5', 'web5', 'http://www.site5.com', '1');
	$New[] = BuyNow('dealer6', 'web6', 'http://www.site6.com', '1');
	$New[] = BuyNow('dealer7', 'web7', 'http://www.site7.com', '1');
	$New[] = BuyNow('dealer8', 'web8', 'http://www.site8.com', '1');
	$New[] = BuyNow('dealer9', 'web9', 'http://www.site9.com', '1');
	$New[] = BuyNow('dealer10', 'web10', 'http://www.site10.com', '0');
	$New[] = BuyNow('dealer11', 'web11', 'http://www.site11.com', '0');
	$New[] = BuyNow('dealer12', 'web12', 'http://www.site12.com', '0');
	$New[] = BuyNow('dealer13', 'web13', 'http://www.site13.com', '0');
	$New[] = BuyNow('dealer14', 'web14', 'http://www.site14.com', '0');

// Define Plug in Variables
$New['dealer'] = $dealer;
$New['web'] = $web;
$New['site'] = $site;
return $New;

// Randomize the array	
shuffle($New);
return $New;

// Make a block
$Tpl->MergeBlock('New', $New);

// Separation of dealers
if($rank = 1){
	$Top = $New[];
}else{
	$Bottom = $New[];
}

// Make Blocks 'Top' and 'Bottom'
$Tpl->MergeBlock('Top', $Top);
$Tpl->MergeBlock('Bottom', $Bottom);
}
?>

 

I used the $rank variable to define the value of the dealer, since the rank may change every month or so.  Can anyone explain to me why I can't get the blocks 'Top' and 'Bottom' to plug into the HTML file?  I get these results http://wilsonelectronics.com/Dealer3.php.

 

Please help  ???

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.