Another Randomization Question

First I would like to thank those that helped me with the first question, works like a charm. The problem I am having now is of the same type of nature, but a little harder to figure out.

This link http://wilsonelectronics.com/Dealer.php takes you to my problem. The box on the right (BUY NOW!) is supposed to be randomized using two factors, Selling volume and Web address.

Right now it is static. I have to input the dealers and their websites in by hand every day, and to keep it random, they are put in a “hat” and drawn out.

I thought of using a variant of the code that was brought up in the last question:

[code]case ‘WhatsNew’:
$New[] = NewProduct(812201, ‘Now Available’);
$New[] = NewProduct(801245, ‘Now Available’);
$New[] = NewProduct(301124, ‘Now Available’);
$New[] = NewProduct(301133, ‘Now Available’);
$New[] = NewProduct(301129, ‘Now Available’);
$New[] = NewProduct(301130, ‘Now Available’);
$New[] = NewProduct(301123, ‘Now Available’);
$New[] = NewProduct(801306, ‘Now Available’);
$New[] = NewProduct(811210, ‘Now Available’);
$New[] = NewProduct(811211, ‘Now Available’);
$New[] = NewProduct(801247, ‘Summer 2007’);
shuffle($New);
$New = array_slice($New, 0, 6);

		$Tpl->MergeBlock('New', $New) ;
	break;[/code]

The only problem I am having is that the top 6 dealers belong in one class, and the bottom two belong to another. I don’t have “access” to the database to put defining markers on these dealers to pull them from, mostly because my company changed hosting services on me. I am just the “Fix-it Man”!

Could I get some suggestions on how to proceed? :(

Thanks for any help I may get!

I think I may have figured it out using:
[php]<?php

function TopDealer($dealer, $web, $site){
	$Top[] = TopDealer('Name1', 'Web1', 'http://www.Site1.com/');
	$Top[] = TopDealer('Name2', 'Web2', 'http://www.Site2.com/');
	$Top[] = TopDealer('Name3', 'Web3', 'http://www.Site3.com/');
	$Top[] = TopDealer('Name4', 'Web4', 'http://www.Site4.com/');
	$Top[] = TopDealer('Name5', 'Web5', 'http://www.Site5.com/');
	$Top[] = TopDealer('Name6', 'Web6', 'http://www.Site6.com/');
	$Top[] = TopDealer('Name7', 'Web7', 'http://www.Site7.com/');
	$Top[] = TopDealer('Name8', 'Web8', 'http://www.Site8.com/');
	$Top[] = TopDealer('Name9', 'Web9', 'http://www.Site9.com/');
	
shuffle($Top);
$Tpl->MergeBlock('Top', $Top);
}

function BottomDealer($dealer, $web, $site){
	$Bottom[] = BottomDealer('Name1', 'Web1', 'http://www.Site1.com/');
	$Bottom[] = BottomDealer('Name2', 'Web2', 'http://www.Site2.com/');
	$Bottom[] = BottomDealer('Name3', 'Web3', 'http://www.Site3.com/');
	$Bottom[] = BottomDealer('Name4', 'Web4', 'http://www.Site4.com/');
	$Bottom[] = BottomDealer('Name5', 'Web5', 'http://www.Site5.com/');
	
shuffle($Bottom);
$Tpl->Mergeblock('Bottom', $Bottom);
}

?>[/php]

But I am not totally sure how to take this data and implement it into the format shown on the right here: http://wilsonelectronics.com/Dealer.php

Any help is appreciated.

[php]

function TopDealer($dealer, $web, $site){
$Top[] = TopDealer(‘Name1’, ‘Web1’, ‘http://www.Site1.com/’);
$Top[] = TopDealer(‘Name2’, ‘Web2’, ‘http://www.Site2.com/’);
$Top[] = TopDealer(‘Name3’, ‘Web3’, ‘http://www.Site3.com/’);
$Top[] = TopDealer(‘Name4’, ‘Web4’, ‘http://www.Site4.com/’);
$Top[] = TopDealer(‘Name5’, ‘Web5’, ‘http://www.Site5.com/’);
$Top[] = TopDealer(‘Name6’, ‘Web6’, ‘http://www.Site6.com/’);
$Top[] = TopDealer(‘Name7’, ‘Web7’, ‘http://www.Site7.com/’);
$Top[] = TopDealer(‘Name8’, ‘Web8’, ‘http://www.Site8.com/’);
$Top[] = TopDealer(‘Name9’, ‘Web9’, ‘http://www.Site9.com/’);

 shuffle($Top);
 return $Top;

}

function BottomDealer($dealer, $web, $site){
$Bottom[] = BottomDealer(‘Name1’, ‘Web1’, ‘http://www.Site1.com/’);
$Bottom[] = BottomDealer(‘Name2’, ‘Web2’, ‘http://www.Site2.com/’);
$Bottom[] = BottomDealer(‘Name3’, ‘Web3’, ‘http://www.Site3.com/’);
$Bottom[] = BottomDealer(‘Name4’, ‘Web4’, ‘http://www.Site4.com/’);
$Bottom[] = BottomDealer(‘Name5’, ‘Web5’, ‘http://www.Site5.com/’);

 shuffle($Bottom);
 return $Bottom;

}

$Tpl->Mergeblock(‘New’, array_merge(TopDealer($dealer, $web, $site), BottomDealer($dealer, $web, $site)));
[/php]

I think that this is need to be logic.

Not exactly what I’m trying to do. I need it to pull 6 of the dealers from the top array and 2 from the bottom and display them like here http://wilsonelectronics.com/Dealer.php on the right. It has to display twice, once on the form page and once on the results page. The “BUY NOW!” section doesn’t need to match on both pages, they just need to be randomized so that when visitors check the page, they don’t see the same results every time they visit. Right now I manually change them everyday, but I cannot change them on weekends or Holidays.

I know there is a way to get the PHP to function with the HTML. Half our website is done with PHP. But like I stated earlier, I did not create the site. Please help.

I created it as a PHP file all in it self:
[php]<?php

// BUY NOW! Dealers.
function TopDealer($dealer, $web, $site){
$Top[] = TopDealer(‘Name1’, ‘Web1’, ‘http://www.site1.com’);
$Top[] = TopDealer(‘Name2’, ‘Web2’, ‘http://www.site2.com’);
$Top[] = TopDealer(‘Name3’, ‘Web3’, ‘http://www.site3.com’);
$Top[] = TopDealer(‘Name4’, ‘Web4’, ‘http://www.site4.com’);
$Top[] = TopDealer(‘Name5’, ‘Web5’, ‘http://www.site5.com’);
$Top[] = TopDealer(‘Name6’, ‘Web6’, ‘http://www.site6.com’);
$Top[] = TopDealer(‘Name7’, ‘Web7’, ‘http://www.site7.com’);
$Top[] = TopDealer(‘Name8’, ‘Web8’, ‘http://www.site8.com’);
$Top[] = TopDealer(‘Name9’, ‘Web9’, ‘http://www.site9.com’);

shuffle($Top);
$Top = array_slice($Top, 0, 6);

$Tpl->MergeBlock('Top', $Top);
}

function BottomDealer($dealer, $web, $site){
	$Bottom[] = BottomDealer('Name1', 'Web1', 'http://www.site1.com');
	$Bottom[] = BottomDealer('Name2', 'Web2', 'http://www.site2.com');
	$Bottom[] = BottomDealer('Name3', 'Web3', 'http://www.site3.com');
	$Bottom[] = BottomDealer('Name4', 'Web4', 'http://www.site4.com');
	$Bottom[] = BottomDealer('Name5', 'Web5', 'http://www.site5.com');
	
shuffle($Bottom);
$Bottom = array_slice($Bottom, 0, 2);

$Tpl->Mergeblock('Bottom', $Bottom);
}

?>[/php]

Used the include function to put it in where it belongs.

Went to the HTML page and added this code:

<table width="100%" border="0" cellspacing="5" cellpadding="15"> <tr> <td width="90%"><p>[Top;block=tr;serial;] </p> <table width="100%" border="0" cellpadding="2" cellspacing="2"> <tr> <td><span class="style13">[Top_1.dealer]</span></a></td> </tr> <tr> <td><a href="[Top_1.site]" onclick="window.location = '[Top_1.site]';" style="display: block; cursor: pointer; text-decoration: none;">[Top_1.web]</a></td> </tr> </table> <hr /> <table width="100%" border="0" cellpadding="2" cellspacing="2"> <tr> <td><span class="style13">[Top_2.dealer]</span></a></td> </tr> <tr> <td><a href="[Top_2.site]" onclick="window.location = '[Top_2.site]';" style="display: block; cursor: pointer; text-decoration: none;">[Top_2.web]</a></td> </tr> </table> <hr /> <table width="100%" border="0" cellpadding="2" cellspacing="2"> <tr> <td><span class="style13">[Top_3.dealer]</span></a></td> </tr> <tr> <td><a href="[Top_3.site]" onclick="window.location = '[Top_3.site]';" style="display: block; cursor: pointer; text-decoration: none;">[Top_3.web]</a></td> </tr> </table> <hr /> <table width="100%" border="0" cellpadding="2" cellspacing="2"> <tr> <td><span class="style13">[Top_4.dealer]</span></a></td> </tr> <tr> <td><a href="[Top_4.site]" onclick="window.location = '[Top_4.site]';" style="display: block; cursor: pointer; text-decoration: none;">[Top_4.web]</a></td> </tr> </table> <hr /> <table width="100%" border="0" cellpadding="2" cellspacing="2"> <tr> <td><span class="style13">[Top_5.dealer]</span></a></td> </tr> <tr> <td><a href="[Top_5.site]" onclick="window.location = '[Top_5.site]';" style="display: block; cursor: pointer; text-decoration: none;">[Top_5.web]</a></td> </tr> </table> <hr /> <table width="100%" border="0" cellpadding="2" cellspacing="2"> <tr> <td><span class="style13">[Top_6.dealer]</span></a></td> </tr> <tr> <td><a href="[Top_6.site]" onclick="window.location = '[Top_6.site]';" style="display: block; cursor: pointer; text-decoration: none;">[Top_6.web]</a></td> </tr> </table> <hr /> [Bottom;block=tr;serial;] <table width="100%" border="0" cellpadding="2" cellspacing="2"> <tr> <td><span class="style13">[Bottom_1.dealer]</span></a></td> </tr> <tr> <td><a href="[Bottom_1.site]" onclick="window.location = '[Bottom_1.site]';" style="display: block; cursor: pointer; text-decoration: none;">[Top_1.web]</a></td> </tr> </table> <hr /> <table width="100%" border="0" cellpadding="2" cellspacing="2"> <tr> <td><span class="style13">[Bottom_2.dealer]</span></a></td> </tr> <tr> <td><a href="[Bottom_2.site]" onclick="window.location = '[Bottom_2.site]';" style="display: block; cursor: pointer; text-decoration: none;">[Bottom_2.web]</a></td> </tr> </table> </td> </tr> for looks.

It returns this:

Maybe I’m going about this all wrong, but I can’t quite figure out how to get it to display the random dealers in the proper places and make it look clean like this: http://wilsonelectronics.com/Dealer.php

That’s what happens when you are thrown into the middle of a website that you had no control over the development of! :lol:

I could still use some help on this.

I’ve tried creating the code into its own PHP file. I tried using the include_once function - nothing. I used it in the actual HTML file - nothing. Can anyone explain what it is I am doing wrong? :frowning:

You provide a piece of code and your project is complex solution.

From my point I see your situation like “black box”. I know what you have at start and at finish and have no idea what you have in this ‘black box’.

Research classes which form html output.

Let me try to fill in the “black box” I have shown what it needs to look like, let see if we can fill in the blanks.

In ‘Dealer3.php’ I have the following:
[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);
$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';

$Top = new TopDealer;
$Bottom = new BottomDealer;
	
$Locator = new DealerLocator;

$ReqArray['FirstName'] = '';
$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';
	$RemReq = $Locator->RemReq;	
}
			
$Tpl = new clsTinyButStrong ;

$Tpl->LoadTemplate('Templates/Main/index.htm') ;

if(isset($Locator->Go))
	$Tpl->MergeBlock('Dealers', $Locator->Dealers);

$Tpl->Show();

?>[/php]
This code tells it to get the information and require the “ZIP” to get certain dealer locations in the database according to proximity of ZIP.
I added the [php]include_once(‘Funct/buynow.php’);[/php] line to reference the php file I am trying to incorporate.
I also added:
[php] $Top = new TopDealer;
$Bottom = new BottomDealer;[/php] to bring in and define the classes I created for the two dealer lists I need to pull from.

I changed the randomization code in ‘Funct/buynow.php’ as such:
[php]<?php

// BUY NOW! Dealers.
class TopDealer{
function TopDealer($dealer, $web, $site){
$Top[] = TopDealer(‘dealer1’, ‘web1’, ‘http://www.site1.com’);
$Top[] = TopDealer(‘dealer2’, ‘web2’, ‘http://www.site2.com’);
$Top[] = TopDealer(‘dealer3’, ‘web3’, ‘http://www.site3.com’);
$Top[] = TopDealer(‘dealer4’, ‘web4’, ‘http://www.site4.com’);
$Top[] = TopDealer(‘dealer5’, ‘web5’, ‘http://www.site5.com’);
$Top[] = TopDealer(‘dealer6’, ‘web6’, ‘http://www.site6.com’);
$Top[] = TopDealer(‘dealer7’, ‘web7’, ‘http://www.site7.com’);
$Top[] = TopDealer(‘dealer8’, ‘web8’, ‘http://www.site8.com’);
$Top[] = TopDealer(‘dealer9’, ‘web9’, ‘http://www.site9.com’);

shuffle($Top);
return $Top;
}

}
class BottomDealer{
function BottomDealer($dealer, $web, $site){
$Bottom[] = BottomDealer(‘dealer1’, ‘web1’, ‘http://www.site1.com’);
$Bottom[] = BottomDealer(‘dealer2’, ‘web2’, ‘http://www.site2.com’);
$Bottom[] = BottomDealer(‘dealer3’, ‘web3’, ‘http://www.site3.com’);
$Bottom[] = BottomDealer(‘dealer4’, ‘web4’, ‘http://www.site4.com’);
$Bottom[] = BottomDealer(‘dealer5’, ‘web5’, ‘http://www.site5.com’);

shuffle($Bottom);
return $Bottom;
}

}
?>[/php] and turned them into classes. This is where I keep getting stuck. I reference the variables in the display HTML files, but I get error codes. If this doesn’t clear up any confusion, then let me know how I can improve my post to help you help me.

All your help has been appreciated, though I am still stuck with this. If there is anything else needed, just request it and I will try to comply, without giving too much personal (company) info out. :)

I need to see function MergeBlock, I think that it is “clsTinyButStrong” class method.

i’m still confused about the files u use.

i guess u use a htm file, wich is a temlate.
then u have a php file where u include Classes/Template.php and then read the htm file to run it tru the $Tpl object.

could u edit ur posts and write the folder and filename before all of the posted codes?

where does the Classes/Template.php file come from?
do you have to pass your array to the template class?

the error should be somwhere there as these [] parts are neither html nor php but maybe some template markups. And they are never replaced by the php array values u created.

I found it in the Template.php file. I hope this helps:
[php]class clsTinyButStrong {

// Public properties
var $Source = ‘’; // Current result of the merged template
var $Render = 3;
var $HtmlCharSet = ‘’;
var $TplVars = array();
var $VarPrefix = ‘’;
var $ObjectRef = false;
var $Protect = true;
// Private properties
var $_LastFile = ‘’; // The last loaded template file
var $_CacheFile = false; // The name of the file to save the content in.
var $_HtmlCharFct = false;
var $Mode = 0;
// Used to be globals
var $ChrOpen = ‘[’;
var $ChrClose = ‘]’;
var $ChrVal = ‘[val]’;
var $ChrProtect = ‘[’;
var $CacheMask = 'cache_tbs
*.php’;
var $TurboBlock = true;
var $MaxEnd = ‘…’;

function clsTinyButStrong($Chrs=’’,$VarPrefix=’’) {
if ($Chrs!==’’) {
$Ok = false;
$Len = strlen($Chrs);
if ($Len===2) { // For compatibility
$this->ChrOpen = $Chrs[0];
$this->ChrClose = $Chrs[1];
$Ok = true;
} else {
$Pos = strpos($Chrs,’,’);
if (($Pos!==false) and ($Pos>0) and ($Pos<$Len-1)) {
$this->ChrOpen = substr($Chrs,0,$Pos);
$this->ChrClose = substr($Chrs,$Pos+1);
$Ok = true;
}
}
if ($Ok) {
$this->ChrVal = $this->ChrOpen.‘val’.$this->ChrClose;
$this->ChrProtect = ‘&#’.ord($this->ChrOpen[0]).’;’.substr($this->ChrOpen,1);
} else {
$this->meth_Misc_Alert(‘Creating instance’,‘Bad argument for tag delimitors ‘’.$Chrs.’’.’);
}
}
$this->VarPrefix = $VarPrefix;
//Cache for formats
if (!isset($GLOBALS[’_tbs_FrmMultiLst’])) {
$GLOBALS[’_tbs_FrmMultiLst’] = array();
$GLOBALS[’_tbs_FrmSimpleLst’] = array();
}
}

// Public methods
function LoadTemplate($File,$HtmlCharSet=’’) {
// Load the file
$x = ‘’;
if (!tbs_Misc_GetFile($x,$File)) return $this->meth_Misc_Alert(‘LoadTemplate Method’,‘Unable to read the file ‘’.$File.’’.’);
// CharSet analysis
if ($HtmlCharSet===’+’) {
$this->Source .= $x;
} else {
$this->Source = $x;
if ($this->_Mode==0) {
$this->_LastFile = $File;
$this->_HtmlCharFct = false;
$this->TplVars = array();
if (is_string($HtmlCharSet)) {
if (($HtmlCharSet!==’’) and ($HtmlCharSet[0]===’=’)) {
$ErrMsg = false;
$HtmlCharSet = substr($HtmlCharSet,1);
if ($this->meth_Misc_UserFctCheck($HtmlCharSet,$ErrMsg)) {
$this->_HtmlCharFct = true;
} else {
$this->meth_Misc_Alert(‘LoadTemplate Method’,$ErrMsg);
$HtmlCharSet = ‘’;
}
}
} elseif ($HtmlCharSet===false) {
$this->Protect = false;
} else {
$this->meth_Misc_Alert(‘LoadTemplate Method’,‘CharSet is not a string.’);
$HtmlCharSet = ‘’;
}
$this->HtmlCharSet = $HtmlCharSet;
}
}
// Automatic fields and blocks
$this->meth_Merge_Auto($this->Source,‘onload’,true,true);
return true;
}

function GetBlockSource($BlockName,$List=false) {
$RetVal = array();
$Nbr = 0;
$Pos = 0;
$FieldOutside = false;
$P1 = false;
while ($Loc = $this->meth_Locator_FindBlockNext($this->Source,$BlockName,$Pos,’.’,false,$P1,$FieldOutside)) {
$P1 = false;
$Nbr++;
$RetVal[$Nbr] = substr($this->Source,$Loc->PosBeg,$Loc->PosEnd-$Loc->PosBeg+1);
if (!$List) return $RetVal[$Nbr];
$Pos = $Loc->PosEnd;
}
if ($List) {
return $RetVal;
} else {
return false;
}
}

function MergeBlock($BlockName,$SrcId,$Query=’’,$PageSize=0,$PageNum=0,$RecKnown=0) {
if ($SrcId===‘cond’) {
$Nbr = 0;
$BlockLst = explode(’,’,$BlockName);
foreach ($BlockLst as $Block) {
$Nbr += $this->meth_Merge_Auto($this->Source,$Block,false,false);
}
return $Nbr;
} else {
return $this->meth_Merge_Block($this->Source,$BlockName,$SrcId,$Query,$PageSize,$PageNum,$RecKnown);
}
}
[/php]
If you need anything else, let me know.

i guess Templates.php is a 3rd party script. Have u tryed to find/read their documentation/manual?

The manual is a little confusing. The one I found is at http://www.tinybutstrong.com and doesn’t exactly make much sense in terms of how to use the array that I have created. I am still working with it though and if you need anymore information that I can provide, please let me know.

I want to get this problem taken care of so I can sleep better at night. :D

(Posts cleaned for better viewing!)

I tried a different approach to see if the results would help. In the ‘Funct/buynow.php’ file:[php]<?php

// BUY NOW! Dealers.
class TopDealer{
function TopDealer($dealer, $web, $site){

	$Top['dealer'] = $dealer;
	$Top['web'] = $web;
	$Top['site'] = $site;
	
	return $Top;
	
	$Top[] = TopDealer('dealer1', 'web1', 'http://www.site1.com');
	$Top[] = TopDealer('dealer2', 'web2', 'http://www.site2.com');
	$Top[] = TopDealer('dealer3', 'web3', 'http://www.site3.com');
	$Top[] = TopDealer('dealer4', 'web4', 'http://www.site4.com');
	$Top[] = TopDealer('dealer5', 'web5', 'http://www.site5.com');
	$Top[] = TopDealer('dealer6', 'web6', 'http://www.site6.com');
	$Top[] = TopDealer('dealer7', 'web7', 'http://www.site7.com');
	$Top[] = TopDealer('dealer8', 'web8', 'http://www.site8.com');
	$Top[] = TopDealer('dealer9', 'web9', 'http://www.site9.com');
	
shuffle($Top);
$Tpl->MergeBlock('Top', $Top);
}

}

class BottomDealer{
function BottomDealer($dealer, $web, $site){

	$Bottom['dealer'] = $dealer;
	$Bottom['web'] = $web;
	$Bottom['site'] = $site;
	
	return $Top;
	
	$Bottom[] = BottomDealer('dealer1', 'web1', 'http://www.site1.com');
	$Bottom[] = BottomDealer('dealer2', 'web2', 'http://www.site2.com');
	$Bottom[] = BottomDealer('dealer3', 'web3', 'http://www.site3.com');
	$Bottom[] = BottomDealer('dealer4', 'web4', 'http://www.site4.com');
	$Bottom[] = BottomDealer('dealer5', 'web5', 'http://www.site5.com');
	
shuffle($Bottom);
$Tpl->MergeBlock('Bottom', $Bottom);
}

}
?>[/php] I defined the values $dealer, $web, and $site. [php] $Top[‘dealer’] = $dealer;
$Top[‘web’] = $web;
$Top[‘site’] = $site;[/php]

After doing this, I put it up on the server and received an error stating that I am missing argument 1, 2 and 3 for topdealer() on line 5, and missing argument 1, 2 and 3 for bottomdealer() on line 29.

Can any one explain to me what arguments I am missing? I thought that the code was clean, or is there more to this setup?

Let me know if more information is needed. I can definately use the help here.

I didn’t understood, where you define this vars?

Can you state the exact error messages you’re getting?

Also, the code you gave us:

[php]

<?php // BUY NOW! Dealers. class TopDealer{ function TopDealer($dealer, $web, $site){ $Top['dealer'] = $dealer; $Top['web'] = $web; $Top['site'] = $site; return $Top; $Top[] = TopDealer('dealer1', 'web1', 'http://www.site1.com'); $Top[] = TopDealer('dealer2', 'web2', 'http://www.site2.com'); $Top[] = TopDealer('dealer3', 'web3', 'http://www.site3.com'); $Top[] = TopDealer('dealer4', 'web4', 'http://www.site4.com'); $Top[] = TopDealer('dealer5', 'web5', 'http://www.site5.com'); $Top[] = TopDealer('dealer6', 'web6', 'http://www.site6.com'); $Top[] = TopDealer('dealer7', 'web7', 'http://www.site7.com'); $Top[] = TopDealer('dealer8', 'web8', 'http://www.site8.com'); $Top[] = TopDealer('dealer9', 'web9', 'http://www.site9.com'); shuffle($Top); $Tpl->MergeBlock('Top', $Top); } } class BottomDealer{ function BottomDealer($dealer, $web, $site){ $Bottom['dealer'] = $dealer; $Bottom['web'] = $web; $Bottom['site'] = $site; return $Top; $Bottom[] = BottomDealer('dealer1', 'web1', 'http://www.site1.com'); $Bottom[] = BottomDealer('dealer2', 'web2', 'http://www.site2.com'); $Bottom[] = BottomDealer('dealer3', 'web3', 'http://www.site3.com'); $Bottom[] = BottomDealer('dealer4', 'web4', 'http://www.site4.com'); $Bottom[] = BottomDealer('dealer5', 'web5', 'http://www.site5.com'); shuffle($Bottom); $Tpl->MergeBlock('Bottom', $Bottom); } } ?>

[/php]

Do you know what it’s doing? Can you tell what the ‘return $Top’ statement in the BottomDealer constructor is doing, or what the statements below the ‘return’ statements will cause your script to do?

Last, why are you making classes for these, when you could be functions just the same, if they don’t need instance variables? Or at least create one class which defines both methods.

The second return $Top was a mistake on my part. I meant for it to be return $Bottom.

I am just as confused as ever before. The error messages are:

Warning: Missing argument 1 for topdealer() in /home/content/w/i/l/wilsonelectron/html/Funct/buynow.php on line 5

Warning: Missing argument 2 for topdealer() in /home/content/w/i/l/wilsonelectron/html/Funct/buynow.php on line 5

Warning: Missing argument 3 for topdealer() in /home/content/w/i/l/wilsonelectron/html/Funct/buynow.php on line 5

Warning: Missing argument 1 for bottomdealer() in /home/content/w/i/l/wilsonelectron/html/Funct/buynow.php on line 29

Warning: Missing argument 2 for bottomdealer() in /home/content/w/i/l/wilsonelectron/html/Funct/buynow.php on line 29

Warning: Missing argument 3 for bottomdealer() in /home/content/w/i/l/wilsonelectron/html/Funct/buynow.php on line 29

As to why I made them classes, it was suggested by another programmer (not on this forum) and I don’t think he is quite sure what he is doing. If he did, he would have helped me figure out what I was doing wrong.

Any way, from my limited knowledge (and I do mean limited), I have no idea what the return value is supposed to return. It should be that the [php]function TopDealer($dealer, $web, $site)[/php] line defines the variables $dealer, $web, $site.

This code:[php]$Top[] = TopDealer(‘dealer1’, ‘web1’, ‘http://www.site1.com’);
$Top[] = TopDealer(‘dealer2’, ‘web2’, ‘http://www.site2.com’);
$Top[] = TopDealer(‘dealer3’, ‘web3’, ‘http://www.site3.com’);
$Top[] = TopDealer(‘dealer4’, ‘web4’, ‘http://www.site4.com’);
$Top[] = TopDealer(‘dealer5’, ‘web5’, ‘http://www.site5.com’);
$Top[] = TopDealer(‘dealer6’, ‘web6’, ‘http://www.site6.com’);
$Top[] = TopDealer(‘dealer7’, ‘web7’, ‘http://www.site7.com’);
$Top[] = TopDealer(‘dealer8’, ‘web8’, ‘http://www.site8.com’);
$Top[] = TopDealer(‘dealer9’, ‘web9’, ‘http://www.site9.com’);[/php]
give $dealer, $web, $site the values that I want shuffled. Hence the [php]shuffle($Top);[/php]

This [php]$Tpl->MergeBlock(‘Top’, $Top);[/php] is supposed to return the value of $Top for placing in the html coding for display - to my knowledge that is.

There are two types of dealers I am inputing thus the TopDealer and BottomDealer functions. They need to be randomized on 2 different pages, the Form page and the Results page.

I am a beginner, learning as I go. If I where to create this all as one big class, say RandomDealer, would that solve problems or create more? What more information is needed to help me?

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! :lol:

I keep trying different coding solutions, but I still have problems with the results. I removed the include_once(Funct/buynow.php) from the ‘Dealer3.php’ file. Instead I placed it into the ‘Templates/Body/Dealer/Form3.htm’ file, hoping that a close proximity to the code will solve the problem. Nope.

I changed the ‘Funct/buynow.php’ file so it now looks like this (with comments trying to explain what I’m trying to do):
[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’);

// 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);
}
?>[/php]

Its just a matter of getting the variables to read in this code:

<td width="90%"><p>[Top;block=tr;]</p> <table width="100%" border="0" cellpadding="2" cellspacing="2"> <tr> <td><span class="style13">[Top_1.dealer]</span></a></td> </tr> <tr> <td><a href="[Top_1.site]" onclick="window.location = '[Top_1.site]';" style="display: block; cursor: pointer; text-decoration: none;">[Top_1.web]</a></td> </tr> </table> <hr /> <table width="100%" border="0" cellpadding="2" cellspacing="2"> <tr> <td><span class="style13">[Top_2.dealer]</span></a></td> </tr> <tr> <td><a href="[Top_2.site]" onclick="window.location = '[Top_2.site]';" style="display: block; cursor: pointer; text-decoration: none;">[Top_2.web]</a></td> </tr> </table> <hr />

Am I even going in the right direction?

Alright, I am pretty sure that people are getting tired of looking through this to see if progress is being made, and I think I have come a long way (with and without help). Now I could REALLY use help understanding the errors I am getting. I took out the include function on the HTML page (‘Templates/Body/Dealer/Form3.htm’). Wasn’t working anyway.

I changed the ‘Funct/buynow.php’ to:
[php]<?php

define(‘RelativePath’, $_SERVER[‘DOCUMENT_ROOT’]);
include_once(‘Classes/Template.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;

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

$Tpl = new clsTinyButStrong ;

// Make Blocks ‘Top’ and ‘Bottom’
$Tpl->MergeBlock(‘Top’, $Top);
$Tpl->MergeBlock(‘Bottom’, $Bottom);

$Tpl->Show();

?>[/php]
I used the include_once(‘Classes/Template.php’) to define where to get the $Tpl variable.

In the ‘Dealer3.php’ I used the include_once('Funct/buynow.php) to include it and use the templates.

The error messages I am getting when I load it are:
TinyButStrong Error (MergeBlock [Top]): Unsupported variable type : ‘NULL’.
TinyButStrong Error (MergeBlock [Bottom]): Unsupported variable type : ‘NULL’.

Can anyone tell me wht I am doing wrong?

Sponsor our Newsletter | Privacy Policy | Terms of Service