Gossamer Forum
Home : General : Perl Programming :

Combining While Statements

Quote Reply
Combining While Statements
Hi All,

I have the following code in a script. and im trying to print the renewal date $renewdate, but to do this i have combined the while statements. it prints the page but with no info.

If i # the second while statement, it prints all the info but not including the $renewdate (obviousley)

Is the syntax correct for the while statements, and or can i combine the queries into one, (i've tried to combine but always get a 500 error)

################ getting next url according to the action type ###########
my ($query,$frm_action,$head_msg,$input_field,$select_name);
if($action_type eq "list_all_dm")
{
$query = qq{select * from order_d,order_m where order_m.order_id=order_d.order_id and order_m.user_id=$user_id and order_d.domain_reg="y" order by order_m.order_id };
$head_msg = "<br><br><font face=$normal_font_style size=$normal_font_size>Below is a list of all your Registered Domain Names.</font><br><br>";
}


################ end of getting next url according to the action type ###########

######### getting renew_mails_tp from conf_table ############
my $query_conf = qq{select renew_mails_tp from conf_table };
my $ret_mysql_conf = select_query($query_conf);
my @queryresult_conf = $ret_mysql_conf->fetchrow_array();
######### end of getting renew_mails_tp from conf_table ############


############ getting all the registered domains whose days left from expiration=renew_mails_tp in table order_d ##############
my $query_domain = qq{select * from order_d, order_m where DATE_SUB(domain_date,INTERVAL $queryresult_conf[0] DAY) <= DATE_SUB(curdate(),INTERVAL domain_period_yr YEAR) and order_m.order_id=order_d.order_id and order_m.user_id=$user_id and domain_reg="y" };
#print "query_domain = " . $query_domain . "<br>";
my $ret_mysql_domain = select_query($query_domain);
my $numrows_domain = $ret_mysql_domain->rows;
my @queryresult_domain;
############ end of getting all the registered domains whose days left from expiration=renew_mails_tp in table order_d ##############



############ getting all the domains returned by the query ##############
my $ret_mysql = select_query($query);
my $numrows = $ret_mysql->rows;
my @queryresult;
if($numrows < 1)
{
print "<font face=$normal_font_style size=$normal_font_size>There are no Registered Domains.</font><br><br>";
footer();
exit;
}
############ getting all the domains returned by the query ##############


print $head_msg;
print "<table width='100%' border='0' cellspacing='0' cellpadding='0'><tr>";


print "<td class='tblhead' width='20%'>Domain Name</td>";
print "<td class='tblhead' width='20%'>Registered On</td>";
print "<td class='tblhead' width='20%'>For Years</td>";
print "<td class='tblhead' width='20%'>Renewal Date</td>";
print "<td class='tblhead' width='20%'>Hosting Plan</td>";
print "</tr>";


while (@queryresult = $ret_mysql->fetchrow_array())
{
while (@queryresult_domain = $ret_mysql_domain->fetchrow_array())
{
print "<tr>";
my $dm = getDomain($queryresult[3]);
my $newdate = &_unix_to_link_date($queryresult[6]);
my $pl_name = getPlanName($queryresult[7]);
my $renewdate = getDomainRenewalDate($queryresult_domain[6]);
{
print "<td align=left>$queryresult[2]$dm</td>";
print "<td align=left>$newdate</td>";
print "<td align=left>$queryresult[4]</td>";
print "<td align=left>$renewdate</td>";
print "<td align=left>$pl_name</td>";
}
print "</tr>";


}#end of while
}##end of second while


print "</table>";


Regards

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

No doubt i'll be back for more answers!
Quote Reply
Re: [mdj1] Combining While Statements In reply to
Please try reformatting your codes, and using [code][/code] tags to show the code. Its impossible to make any real sense of the structure etc in its current layout.

Cheers

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [Andy] Combining While Statements In reply to
Code:


################ getting next url according to the action type ###########
my ($query,$frm_action,$head_msg,$input_field,$select_name);
if($action_type eq "list_all_dm")
{
$query = qq{select * from order_d,order_m where order_m.order_id=order_d.order_id and order_m.user_id=$user_id and order_d.domain_reg="y" order by order_m.order_id };
$head_msg = "<br><br><font face=$normal_font_style size=$normal_font_size>Below is a list of all your Registered Domain Names.</font><br><br>";
}

################ end of getting next url according to the action type ###########

######### getting renew_mails_tp from conf_table ############
my $query_conf = qq{select renew_mails_tp from conf_table };
my $ret_mysql_conf = select_query($query_conf);
my @queryresult_conf = $ret_mysql_conf->fetchrow_array();
######### end of getting renew_mails_tp from conf_table ############

############ getting all the registered domains whose days left from expiration=renew_mails_tp in table order_d ##############
my $query_domain = qq{select * from order_d, order_m where DATE_SUB(domain_date,INTERVAL $queryresult_conf[0] DAY) <= DATE_SUB(curdate(),INTERVAL domain_period_yr YEAR) and order_m.order_id=order_d.order_id and order_m.user_id=$user_id and domain_reg="y" };
#print "query_domain = " . $query_domain . "<br>";
my $ret_mysql_domain = select_query($query_domain);
my $numrows_domain = $ret_mysql_domain->rows;
my @queryresult_domain;
############ end of getting all the registered domains whose days left from expiration=renew_mails_tp in table order_d ##############


############ getting all the domains returned by the query ##############
my $ret_mysql = select_query($query);
my $numrows = $ret_mysql->rows;
my @queryresult;
if($numrows < 1)
{
print "<font face=$normal_font_style size=$normal_font_size>There are no Registered Domains.</font><br><br>";
footer();
exit;
}
############ getting all the domains returned by the query ##############

print $head_msg;
print "<table width='100%' border='0' cellspacing='0' cellpadding='0'><tr>";

print "<td class='tblhead' width='20%'>Domain Name</td>";
print "<td class='tblhead' width='20%'>Registered On</td>";
print "<td class='tblhead' width='20%'>For Years</td>";
print "<td class='tblhead' width='20%'>Renewal Date</td>";
print "<td class='tblhead' width='20%'>Hosting Plan</td>";
print "</tr>";

while (@queryresult = $ret_mysql->fetchrow_array())
{
#while (@queryresult_domain = $ret_mysql_domain->fetchrow_array())
#{
print "<tr>";
my $dm = getDomain($queryresult[3]);
my $newdate = &_unix_to_link_date($queryresult[6]);
my $pl_name = getPlanName($queryresult[7]);
my $renewdate = getDomainRenewalDate($queryresult_domain[6]);
{
print "<td align=left>$queryresult[2]$dm</td>";
print "<td align=left>$newdate</td>";
print "<td align=left>$queryresult[4]</td>";
print "<td align=left>$renewdate</td>";
print "<td align=left>$pl_name</td>";
}
print "</tr>";

}#end of while
#}##end of second while

print "</table>";
Regards

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

No doubt i'll be back for more answers!
Quote Reply
Re: [mdj1] Combining While Statements In reply to
Can anyone tell me why the $renewdomain will not print anything, i have it working fine on other pages in the site i just cant get it to print on this one, Im starting to go bald now!!

Code:
################ getting next url according to the action type ###########
my ($query,$query_conf,$query_domain,$frm_action,$head_msg,$input_field,$select_name);
if($action_type eq "list_all_dm")
{
$query = qq{select * from order_d,order_m where order_m.order_id=order_d.order_id and order_m.user_id=$user_id and order_d.domain_reg="y" order by order_m.order_id };
$query_conf = qq{select renew_mails_tp from conf_table };
$query_domain = qq{select * from order_d,order_m where DATE_SUB(domain_date,INTERVAL $queryresult_conf[0] DAY) <= DATE_SUB(curdate(),INTERVAL domain_period_yr YEAR) and order_m.order_id=order_d.order_id and order_m.user_id=$user_id and order_d.domain_reg="y" };
$head_msg = "<br><br><font face=$normal_font_style size=$normal_font_size>Below is a list of all your Registered Domain Names.</font><br><br>";
}

################ end of getting next url according to the action type ###########

######### getting renew_mails_tp from conf_table ############
#my $query_conf = qq{select renew_mails_tp from conf_table };
my $ret_mysql_conf = select_query($query_conf);
my @queryresult_conf = $ret_mysql_conf->fetchrow_array();
######### end of getting renew_mails_tp from conf_table ############

############ getting all the registered domains whose days left from expiration=renew_mails_tp in table order_d ##############
#my $query_domain = qq{select * from order_d, order_m where DATE_SUB(domain_date,INTERVAL $queryresult_conf[0] DAY) <= DATE_SUB(curdate(),INTERVAL domain_period_yr YEAR) and order_m.order_id=order_d.order_id and order_m.user_id=$user_id and domain_reg="y" };
#print "query_domain = " . $query_domain . "<br>";
my $ret_mysql_domain = select_query($query_domain);
my $numrows_domain = $ret_mysql_domain->rows;
my @queryresult_domain;
############ end of getting all the registered domains whose days left from expiration=renew_mails_tp in table order_d ##############

############ getting all the hosting plans whose days left from expiration=renew_mails_tp in table order_d ##############
#my $query_plan = qq{select * from order_d, order_m where DATE_SUB(plan_date,INTERVAL $queryresult_conf[0] DAY) <= DATE_SUB(curdate(),INTERVAL plan_duration_mnth MONTH) and plan_id<>"0" and plan_id<>"" and order_m.order_id=order_d.order_id and order_m.user_id=$user_id};
#print "query_plan = " . $query_plan . "<br>";
my $ret_mysql_plan = select_query($query_plan);
my $numrows_plan = $ret_mysql_plan->rows;
my @queryresult_plan;
############ end of getting all the hosting plans whose days left from expiration=renew_mails_tp in table order_d ##############


############ getting all the domains returned by the query ##############
my $ret_mysql = select_query($query);
my $numrows = $ret_mysql->rows;
my @queryresult;
if($numrows < 1)
{
print "<font face=$normal_font_style size=$normal_font_size>There are no Registered Domains.</font><br><br>";
footer();
exit;
}
############ getting all the domains returned by the query ##############

print $head_msg;
print "<table width='100%' border='0' cellspacing='0' cellpadding='0'><tr>";

print "<td class='tblhead' width='20%'>Domain Name</td>";
print "<td class='tblhead' width='20%'>Registered On</td>";
print "<td class='tblhead' width='20%'>For Years</td>";
print "<td class='tblhead' width='20%'>Hosting Plan</td>";
print "<td class='tblhead' width='20%'>Renewal Date</td>";
print "</tr>";

while (@queryresult = $ret_mysql->fetchrow_array())
{

print "<tr>";
my $dm = getDomain($queryresult[3]);
my $newdate = &_unix_to_link_date($queryresult[6]);
my $pl_name = getPlanName($queryresult[7]);

{
print "<td align=left>$queryresult[2]$dm</td>";
print "<td align=left>$newdate</td>";
print "<td align=left>$queryresult[4]</td>";
print "<td align=left>$pl_name</td>";
}
}#end of while

while (@queryresult_domain = $ret_mysql_domain->fetchrow_array())
{

my $renewdate = getDomainRenewalDate($queryresult_domain[6]);

{


print "<td align=left>$renewdate</td>";

}
print "</tr>";


}##end of second while

print "</table>";
Regards

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

No doubt i'll be back for more answers!
Quote Reply
Re: [mdj1] Combining While Statements In reply to
Do you mean $renewdate? If not, then you have not declared $renewdomain in the codes you posted.
========================================
Buh Bye!

Cheers,
Me
Quote Reply
Re: [Stealth] Combining While Statements In reply to
Yes sorry $renewdate
Regards

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

No doubt i'll be back for more answers!