我的购物车中的产品不会在结帐时显示或在mysql中作为订单发布

时间:2013-08-02 04:34:44

标签: php

我在订购时从我的数据库中获取了我的信息,但我使用checkorders.php页面查看订单,但它们不会显示

这是我认为给出问题的编码吗?

<?
    session_start();

include("includes/db.php");
include("includes/phpscripts.php");
include('includes/settings.php');
?>
<?
if($_GET["action"] == "save")
{
$MID = str_replace("'","''",$_REQUEST['MID']);  
$GETFIRSTNAME = str_replace("'","''",$_REQUEST['FIRSTNAME']);  
$GETLASTNAME = str_replace("'","''",$_REQUEST['LASTNAME']);  
$GETEMAIL = str_replace("'","''",$_REQUEST['EMAIL']);  
$GETPASSWORD = str_replace("'","''",$_REQUEST['PASSWORD']); 
$GETPHONE = str_replace("'","''",$_REQUEST['PHONE']);  
$GETADDRESS1 = str_replace("'","''",$_REQUEST['ADDRESS1']);  
$GETADDRESS2 = str_replace("'","''",$_REQUEST['ADDRESS2']);  
$GETCITY = str_replace("'","''",$_REQUEST['CITY']);  
$GETSTATE = str_replace("'","''",$_REQUEST['STATE']);  
$GETPAID = str_replace("'","''",$_REQUEST['PAID']);   

$dbh=mysql_connect ("localhost", "florida_fields", "fields321") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("florida_fields");

$query = "UPDATE MEMBERS SET FIRSTNAME = '$GETFIRSTNAME', LASTNAME = '$GETLASTNAME', EMAIL = '$GETEMAIL', PASSWORD = '$GETPASSWORD', PHONE = '$GETPHONE', ADDRESS1 = '$GETADDRESS1', ADDRESS2 = '$GETADDRESS2', CITY = '$GETCITY', STATE = '$GETSTATE', PAID = '$GETPAID' WHERE MID = '$MID'";
$result = mysql_query($query) or die('Query failed: ' . mysql_error());
}

if($_GET["action"] == "gopaid")
{
$OID = str_replace("'","''",$_REQUEST['OID']);  
$dbh=mysql_connect ("localhost", "florida_fields", "fields321") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("florida_fields");

$query = "UPDATE ORDERS SET PAID = '1' WHERE OID = '$OID'";
$result = mysql_query($query) or die('Query failed: ' . mysql_error());
}
if($_GET["action"] == "gounpaid")
{
$OID = str_replace("'","''",$_REQUEST['OID']);  
$dbh=mysql_connect ("localhost", "florida_fields", "fields321") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("florida_fields");

$query = "UPDATE ORDERS SET PAID = '0' WHERE OID = '$OID'";
$result = mysql_query($query) or die('Query failed: ' . mysql_error());
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?echo$SHOWTITLE?></title>
<meta name="description" content="<?echo$SHOWDESC?>" />
<meta name="keywords" content="<?echo$SHOWKEYS?>">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="css/menu.css" rel="stylesheet" type="text/css" />
<script>    
function Edit(id)
    { 
window.open("editor/examples/editor1.php?ID="+id,"test","toolbar=no,location=no,status=no,resizable=yes,scrollbars=auto,width=700,height=600,top=50,left=50");      
    } 
</script>
<script>    
function printorder(id)
    { 
window.open("vieworder.php?ID="+id,"test","toolbar=no,location=no,status=no,resizable=yes,scrollbars=auto,width=700,height=600,top=50,left=50");        
    } 
</script>
<script language="JavaScript">
<!--
function Form1()
        {

        if(document.form2.NAME.value=="")
            {
            alert("Please Enter Page Name");
            return false;
            }
        }
function Form2()
        {

        if(document.form3.SUBONENAME.value=="")
            {
            alert("Please Enter Sub Page Name");
            return false;
            }
        }
function Form3()
        {

        if(document.form4.SUBTWONAME.value=="")
            {
            alert("Please Enter Sub Page Name");
            return false;
            }
        }   
//-->
</script>
<script>    
function DeletePage(id)
{ 
if(confirm("Are you really really sure you want to delete this page?")) 
{
  if(confirm("Ok, don't tell me I didn't warn you! You can not undo this one you know?")) 
{
  parent.location="index.php?action=delete&DID="+id
} 
} 

}
</script>
<script>    
function DeleteOrder(id)
{ 
if(confirm("Are you really really sure you want to delete this order?")) 
{
  if(confirm("Ok, don't tell me I didn't warn you! You can not undo this one you know?")) 
{
  parent.location="checkorders.php?action=deleteorder&DID="+id
} 
} 

}
</script>
<?
if($_GET["action"] == "deletemember")
{
$dbh=mysql_connect ("localhost", "florida_fields", "fields321") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("florida_fields");

$TID = $_REQUEST['DID'] ;

$sql = "DELETE FROM MEMBERS WHERE MID = '$TID'";
mysql_query($sql);

//mysql_close();
}
?>
<?
if($_GET["action"] == "deleteorder")
{
$dbh=mysql_connect ("localhost", "florida_fields", "fields321") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("florida_fields");

$TID = $_REQUEST['DID'] ;

$sql = "DELETE FROM ORDERS WHERE OID = '$TID'";
mysql_query($sql);

//mysql_close();
}
?>
<script>    
function DeleteMember(id)
{ 
if(confirm("Are you really really sure you want to delete this member?")) 
{
  if(confirm("Ok, don't tell me I didn't warn you! You can not undo this one you know?")) 
{
  parent.location="members.php?action=deletemember&DID="+id
} 
} 

}
</script>
<script>
function showit(it) {
  document.getElementById(it).style.display = "block";
}

function hideit(it) {
  document.getElementById(it).style.display = "none";
}

function hideall() {
  for (var i=1; i<=2; i++) {
    hideit("x" + i);
  }
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
</script>
<style type="text/css">
<!--
body {
    background-image: url(back.jpg);
    margin-left: 0px;
    margin-top: 0px;
    margin-right: 0px;
    margin-bottom: 0px;
}
-->
</style>
<link href="css/florida.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.style4 {color: #FFFFFF}
-->
</style>
</head>

<body onload="MM_preloadImages('images/button1_2.jpg','images/button2_2.jpg')">
<table width="1024" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td align="center" valign="top" background="mainback.jpg"><table width="944" height="717" border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td height="109"><div align="right"><a href="https://www.facebook.com/Grassfedmalabar"><img src="images/facebook.jpg" width="310" height="50" border="0" /></a><br />
            <a href="memberlogin.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image4','','images/button1_2.jpg',1)"><img src="images/button1_1.jpg" name="Image4" border="0" id="Image4" /></a><img src="images/button2.jpg" width="32" height="59" /><a href="join.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image6','','images/button2_2.jpg',1)"><img src="images/button2_1.jpg" name="Image6" width="129" height="59" border="0" id="Image6" /></a></div></td>
      </tr>
      <tr>
        <td height="159">&nbsp;</td>
      </tr>
      <tr>
        <td valign="top"><table width="941" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td valign="top">&nbsp;</td>
            <td valign="top" class="TextD">&nbsp;</td>
          </tr>
          <tr>
            <td width="156" valign="top"><table width="155" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td background="images/menuback.jpg"><br />
                  <table width="156" border="0" cellpadding="0" cellspacing="0">
                  <tr>
                    <td width="28">&nbsp;</td>
                    <td width="128" valign="top"><? include("menu.php");?>
                      <br />
                      <br /></td>
                  </tr>
                </table>
                  <div align="left"><img src="images/menubottom.jpg" width="149" height="250" /><br />
                  </div></td>
              </tr>
            </table>
            <?php
if ($_SESSION['florida']=='fields321')
{
?>   
<div align="left">
              <span class="link2">&nbsp;&nbsp;&nbsp;&nbsp;• <a href="addpage.php">Edit Menu</a></span><br />
              <span class="link2">&nbsp;&nbsp;&nbsp;&nbsp;• <a href="index.php?action=logout">Logout</a></span><br />
              <span class="link2">&nbsp;&nbsp;&nbsp;&nbsp;• <a href="pagesettings.php">Page Settings</a></span><br />
<span class="link2">&nbsp;&nbsp;&nbsp;&nbsp;• <a href="sortmenu.php">Sort Menu</a></span><br />
<span class="link2">&nbsp;&nbsp;&nbsp;&nbsp;• <a href="members.php">Members</a></span><br />
<span class="link2">&nbsp;&nbsp;&nbsp;&nbsp;• <a href="checkorders.php">Orders</a></span><br />
<span class="link2">&nbsp;&nbsp;&nbsp;&nbsp;• <a href="addcat.php">Edit Gallery</a></span><br />
</div>
<?
}
?>
</td>
            <td width="779" valign="top"><table width="777" border="0" cellspacing="2" cellpadding="2">
              <tr>
                <td width="123" bgcolor="#AABE3B" class="style4 TextB"><div align="left"><strong>First Name</strong></div></td>
                <td width="123" bgcolor="#AABE3B" class="style4 TextB"><div align="left"><strong>Last Name</strong></div></td>
                <td width="142" bgcolor="#AABE3B" class="style4 TextB"><div align="left"><strong>Order</strong></div></td>
                <td width="142" bgcolor="#AABE3B" class="style4 TextB"><div align="left"><strong>Pick-Up</strong></div></td>
                <td width="84" bgcolor="#AABE3B" class="style4 TextB"><div align="left"><strong>Method</strong></div></td>
                <td width="206" bgcolor="#AABE3B" class="style4 TextB"><div align="left"><strong>Printed</strong></div></td>
                <td width="61" bgcolor="#AABE3B" class="style4 TextB"><div align="left"></div></td>
              </tr>
<? 
$dbh=mysql_connect ("localhost", "florida_fields", "fields321") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("florida_fields");

$query = "SELECT * FROM ORDERS WHERE ORDERDATE <> '' ORDER BY OID";

$result = mysql_query($query) or die('Query failed: ' . mysql_error());

$num=mysql_numrows($result);
?>
<?
$i=0;
while($i<$num) {

我认为这是我的问题,但我不太确定

$CART=mysql_result($result,$i,"CART");
$OID=mysql_result($result,$i,"OID");
$PAID=mysql_result($result,$i,"PAID");
$PAYMETHOD=mysql_result($result,$i,"PAYMETHOD");
$CUSTOMER=mysql_result($result,$i,"CUSTOMER");
$PICKUP=mysql_result($result,$i,"ORDERDATE");
if($PAID=='0')
{
$PAID2 = "No";
}
else
{
$PAID2 = "Yes";
}
$query2 = "SELECT * FROM MEMBERS WHERE MID = '$CUSTOMER' ";

$result2 = mysql_query($query2) or die('Query failed: ' . mysql_error());

$num2=mysql_numrows($result2);
if($num2!=NULL)
{
$FIRSTNAME=mysql_result($result2,$i2,"FIRSTNAME");
$LASTNAME=mysql_result($result2,$i2,"LASTNAME");
}
?>
              <tr>
                <td valign="top" class="TextB"><div align="left"><? echo $FIRSTNAME?></div></td>
                <td valign="top" class="TextB"><div align="left"><? echo $LASTNAME?></div></td>
                <td valign="top" class="TextB"><div align="left"><a href="javascript:printorder('<? echo $OID?>');">View Order</a></div></td>
                <td valign="top" class="TextB"><div align="left"><? echo $PICKUP?></div></td>
                <td valign="top" class="TextB"><div align="left"><? echo $PAYMETHOD?></div></td>
                <td valign="top" 
<? if($PAID=='0'){?>bgcolor="#FF0000" class="TextB"><div align="left"><a href="checkorders.php?action=gopaid&OID=<? echo $OID?>"><font color="#FFFFFF"><? echo $PAID2?></font></a></div><? }?>
<? if($PAID=='1'){?>bgcolor="#00FF00" class="TextB"><div align="left"><a href="checkorders.php?action=gounpaid&OID=<? echo $OID?>"><font color="#FFFFFF"><? echo $PAID2?></font></a></div><? }?></td>
                <td valign="top" class="TextB"><div align="left">(<a href="javascript:DeleteOrder('<? echo $OID?>');">Delete</a>)</div></td>
              </tr>

              <tr>
                <td colspan="7" class="TextB"><hr /></td>
                </tr>
 <?
    $i++;
    }
    ?>
            </table>
              <br /></td>
          </tr>

          <?
if ($_SESSION['florida']=='fields321')
{
?>
          <?
          }
          ?>
        </table></td>
      </tr>
    </table>
    <br /></td>
  </tr>

  <tr>
    <td align="center">&nbsp;</td>
  </tr>
</table>
</body>
</html>

0 个答案:

没有答案