Can anyone tell me how to incorporate the following to work together.
I have a Select statement which grabs two values called startdate and cycle from our database which looks like this:
$ID=mysql_fetch_row(mysql_query("SELECT ID, startdate, cycle FROM customer_info WHERE ID='".addslashes(trim($orderID))."'"));
if ($ID[0]<=0){
$error.="There is no matching Order ID in our Database.<br>\n";
}
startdate holds a date value and cycle holds any of these values (m1, m6, or y1). m1 would be for monthly billing, m6 would be semi-annual, and y1 would be annual billing.
How do I pass those to values into the next script and then return to me a new startdate in the variable $startdate?
The following script was written by someone else who said it should work for me with a little tweaking. Unfortunately, I'm not good enough with php to understand what I need to tweak.
<?PHP
// return next due date
# which == 0 == return timestamp from todays date
# which == 1 == use hosting order ogcreate to build next due date
function find_next_due($payment_term, $oid, $which)
{
$payment_term=strtolower(stripslashes(trim($payment_term)));
$payment_term=str_replace("-", "_", $payment_term);
if ($payment_term=="monthly") { $payment_term="1"; }
else if ($payment_term=="quarterly") { $payment_term="3"; }
else if ($payment_term=="semi_annual") { $payment_term="6"; }
else if ($payment_term=="annual") { $payment_term="12"; }
if ($which==0)
{
return "1|".mktime(date("h"), date("i"), date("s"), (date("m")+$payment_term), date("d"), date("Y"))."|";
}
else if ($which==1)
{
$query="select ";
$query.="next_due_date, ";
$query.="ogcreate, ";
$query.="domain_name ";
$query.="from ";
$query.="hosting_order ";
$query.="where ";
$query.="oid='".addslashes(trim($oid))."'";
$rs=mysql_fetch_row(mysql_query($query));
$next_due_date=stripslashes(trim($rs[0]));
$og=stripslashes(trim($rs[1]));
$domain_name=stripslashes(trim($rs[2]));
if ($next_due_date==""||$next_due_date=="---")
{
$i=0; $x=0;
while ($i==0)
{
if ($x==24) { return "0|".$domain_name."|"; }
else
{
$next_due_date=create_next_due($next_due_date, $payment_term);
if ($next_due_date>time()) { return "1|".$next_due_date."|"; }
$x+=1;
}
}
}
else
{
$hour=date("h", $next_due_date);
$min=date("i", $next_due_date);
$sec=date("s", $next_due_date);
$month=date("m", $next_due_date);
$day=date("d", $next_due_date);
$year=date("Y", $next_due_date);
return "1|".mktime($hour, $min, $sec, ($month+$payment_term), $day, $year)."|";
}
}
}
function create_next_due($og, $payment_term)
{
$hour=date("h", $og);
$min=date("i", $og);
$sec=date("s", $og);
$month=date("m", $og);
$day=date("d", $og);
$year=date("Y", $og);
$data=mktime($hour, $min, $sec, ($month+$payment_term), $day, $year);
return $data;
}
?>
Thanks in advance for your help.