Gossamer Forum
Home : General : Databases and SQL :

Stopping Script from looping

Quote Reply
Stopping Script from looping
Hi All,

I know there is probably a simple way to stop this, but the script below, just continues to loop printing the same results over and over again. What can i add / change so that it only outputs the results once?

Code:


############ getting all hosting accounts ##############
my $query_host = qq{select * from order_d, order_m where order_d.plan_id >=1};
my $ret_mysql_host = select_query($query_host);
my $numrows_host = $ret_mysql_host->rows;
my @queryresult_host;
############ end of getting all hosting accounts ##############

if($numrows_host < 1)
{
print "<br><br><b>All Hosting Accounts</b>";
print "<table border=0 cellspacing='2' cellpadding='2' width='90%'>";
print "<tr>";
print "<td width='20%' valign=top>There are no hosting accounts.</td>";
print "</tr></table>";
}
else {

print "<br><b>All Hosting Accounts</b>";
print "<table border=0 cellspacing='2' cellpadding='2' width='90%'>";
print "<tr>";
print "<td class='tblhead' width='20%' valign=top>Hosting Account Domain Name - Click Domain To Renew</td>";
print "<td class='tblhead' width='20%' valign=top>Renewal Date</td></tr>";
while (@queryresult_host = $ret_mysql_host->fetchrow_array())
{

print "<tr>";
my $dm = getDomain($queryresult_host[3]);
my $prenewdate = getHostingRenewalDate($queryresult_host[10]);
my $pl_name = getPlanName($queryresult_host[7]);

print "<td><a href=order_plan_hosting.pl?order_recur_id=$queryresult_host[0]&order_section=recur_plan>$queryresult_host[2]$dm</a> [$pl_name]</td>";
print "<td>$prenewdate</td>";
print "</tr>";
}
print "</table>";
}


Thanks in advance guys.
Regards

Mark
http://www.host4.me.uk

No doubt i'll be back for more answers!
Quote Reply
Re: [mdj1] Stopping Script from looping In reply to
hm... that shouldn't be happening. the while loop should break when nothing is returned after the last record fetch. try removing
Code:
my @queryresult_host;

and changing the while loop to:
Code:
while (my @queryresult_host = $ret_mysql_host->fetchrow_array())

Philip
------------------
Limecat is not pleased.