Lets try a new approach to this. I know what I want it to look like when completed. http://wilsonelectronics.com/Dealer.php (the BUY NOW section).
I know that I have 9 people that go into the top 6 slots. I know that I have 5 people that go into the bottom 2 slots. They have the Dealer Name, Dealer Site (what is shown) and the Dealer Web Address (url that is hidden). Those three things need to be given values to input into the HTML page. I also know that they all have to be inputed randomly (sorry for bad grammar).
If I could put the values in the Database, it would save me TONS of time. Since I cannot (access denied!), I have to assign the values manually (hence the coding screw-ups and lack of a clue).
I know I have to use this input in 3 files: Dealer3.php, Form3.htm, and Disp3.htm.
Dealer3.php has this coding (added comments to explain):
[php]<?php
define('RelativePath', $_SERVER['DOCUMENT_ROOT']);
include_once('Classes/Template.php');
include_once('Classes/DBHandle.php');
include_once('Funct/Dealer3.php');
include_once('Funct/buynow.php');
$RootPath = './';
$Num = rand(1,12); // Header randomization
$Img = ''.$Num.'';
if ($Img<=4){
$Sboost = 'ViewProduct.php?ID=123';
}elseif ($Img>=9){
$Sboost = 'Misc.php?Page=AboutUs';
}else{
$Sboost = 'ViewProduct.php?ID=126';
}
$SubTemp = 'Templates/Body/Dealer/Form3.htm'; //Start page
$Locator = new DealerLocator; //Defines what to look for when summited
$ReqArray['FirstName'] = ''; //Form summition
$ReqArray['LastName'] = '';
$ReqArray['Phone'] = '';
$ReqArray['Zip'] = '';
$ReqArray['Email'] = '';
if(sizeof($_POST) > 0)
foreach($_POST as $Key => $Value)
$$Key = $Value;
else
foreach($ReqArray as $Key => $Value)
$$Key = $Value;
if(isset($Locator->Failed))
$Error = $Locator->Failed;
else
$Error = '';
if(isset($Locator->Go)){
$SubTemp = 'Templates/Body/Dealer/Disp3.htm'; //Dealer Page
$RemReq = $Locator->RemReq;
}
$Tpl = new clsTinyButStrong ;
$Tpl->LoadTemplate('Templates/Main/index.htm') ;
if(isset($Locator->Go))
$Tpl->MergeBlock('Dealers', $Locator->Dealers);
$Tpl->Show();
?>[/php]
The ‘Funct/Dealer3.php’ page has coding for email verification, zip code verification and dealer limitations (dealer type and how many of that type to display).
The ‘Funct/buynow.php’ is the file I am trying to use to randomize “top web dealers” into a Buy It Now section (referenced in the above url) so visitors will not have to input any information if they don’t feel like it (hence BUY NOW).
[php]<?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’);
// Randomize the array
shuffle($New);
// Separation of dealers
if($rank = 1){
$Top = $New[‘dealer’‘web’‘site’];
}else{
$Bottom = $New[‘dealer’‘web’‘site’];
}
}
?>[/php]
My code is not perfect and I am not entirely sure how to make it work. I was thinking, after checking all the posts on this forum, that maybe I am going about it all the wrong way. Instead of using two different functions, I created one big function, used a ranking variable (1 or 0), used an if-else statement, and somehow need to randomize the output into the proper slots.
Am I pointing myself in the right direction? Comments, suggestions and help are much valued at this point. We’ll see if I can get this all to work properly!