order.phtml (a smaller window that is popped up showing shopping cart contents) calls orderdb.phtml to update the order in the database. That works. Now I want to recall order.phtml if the chkout flag = n OR close the window and call checkout.phtml in the main window. I was hoping to have orderdb.phtml not display anything and have these actions performed as fast as possible. The following code does nothing after the database update. I was a little more successful doing an onload=doit() to a javascript function (see second example)but that did not close the window. It did do the recall of order.phtml. What I don't understand is if I put doit() inside the script tag, it does not work at all.
<?
function addquotes($the_string)
{
// a function to put single quotes around character-fields
$the_string = "'" . $the_string ."'";
return $the_string;
}
// Connect to database
$db = mysql_connect("localhost", "root");
mysql_select_db("sm",$db);
// Update the size(s), color(+code), qty for recalc and checkout.
for ( $i=0; $i<$count; $i++ )
{
$query_db = "update orderitems set qty = $qty[$i], "
. "tsize = '" . $tsize[$i] . "', "
. "bsize = '" . $bsize[$i] . "', "
. "color = '" . $color[$i] . "' where oiid = $oiid[$i]";
$result = mysql_query( $query_db, $db );
// If we have an error..... (need better)
if ( mysql_errno() != 0 )
{
$errormsg = mysql_error();
include( 'error.phtml' );
return;
}
}
// Now, where do we go.
// If checkout, close window and go to checkout with order number
if ( $chkout == 'y' )
{
?>
document.window.close();
<?
}
else // must be a recalc so call order.phtml
{
echo "<META HTTP-EQUIV=refresh content=0;URL=order.phtml>; ";
}
?>
}
second example...............
<SCRIPT>
<!--
function goOpener(myLink,closeme,closeonly)
{
if (! (window.focus && window.opener))return true;
window.opener.focus();
if (! closeonly)window.opener.location.href=myLink.href;
if (closeme)window.close();
return false;
}
function checkout(myLink,closeme,closeonly)
{
if (! (window.focus && window.opener))return true;
window.opener.focus();
if (! closeonly)window.opener.location.href="checkout.phtml?order=<?echo $ordnum?>";
if (closeme)window.close();
return false;
}
</script>
</head>
function doit()
{
<?
function addquotes($the_string)
{
// a function to put single quotes around character-fields
$the_string = "'" . $the_string ."'";
return $the_string;
}
// Connect to database
$db = mysql_connect("localhost", "root");
mysql_select_db("sm",$db);
echo "checkout = " . $chkout;
//echo "count = " . $count;
// Update the size(s), color(+code), qty for recalc and checkout.
for ( $i=0; $i<$count; $i++ )
{
$query_db = "update orderitems set qty = $qty[$i], "
. "tsize = '" . $tsize[$i] . "', "
. "bsize = '" . $bsize[$i] . "', "
. "color = '" . $color[$i] . "' where oiid = $oiid[$i]";
//echo $query_db;
$result = mysql_query( $query_db, $db );
// If we have an error..... (need better)
if ( mysql_errno() != 0 )
{
$errormsg = mysql_error();
include( 'error.phtml' );
return;
}
}
// Now, where do we go.
// If checkout, close window and go to checkout with order number
if ( $chkout == 'y' )
{
?>
document.window.close();
<?
}
else // must be a recalc so call order.phtml
{
echo "<META HTTP-EQUIV=refresh content=0;URL=order.phtml>; ";
}
?>
}
<BODY bgcolor="white" onLoad="doit()">
hello
</body>