⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 viewpsale.php

📁 一个php的公司信息系统
💻 PHP
字号:
<?
  require('session.inc');
  require('connect.inc');
  if ($usern!=-1)
  {
    html_header("非法登录,拒绝访问 - ACCESS DENIED",'<META http-equiv="refresh" content="3; url=index.php">');
    echo "<td align=right valign=center><br>
    Sorry, 您正想非法登录本系统,请正常登录!<br>系统会在3秒后自动返回登录页面。
    <br><br><br><a href=index.viewpsale.php>返回登录</a></td>";
    html_footer();
  }
  else
  {
?>
<html>
<head>
<title>::: DATABASE 化妆品公司数据库管理系统 - 查询产品销售</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="common.css" type="text/css">
</head>

<body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="770" border="0" cellspacing="0" cellpadding="0" align="center" height="450">
  <tr>
    <td background="images/bg2.jpg">
      <table width="770" border="0" cellspacing="0" cellpadding="0" height="450">
        <tr>
           <td>
            <table width="100%" border="0" cellspacing="0" cellpadding="0" height="450">
              <tr>
                <td height="140" class="bigh"><font color=#ff3333>查询产品销售</font></td>
              </tr>
              <tr>
                <td valign=top>
<?
  if ($step==0)
  {
    $str_sql="select distinct(SALERC.pid) as pid,pname from PRODUCTTB,SALERC where SALERC.pid=PRODUCTTB.pid;";
    $result=mysql_db_query($db,$str_sql,$link_id);
    if (!$result) html_error_exit('MySQL查询命令失败!');
    else
    {
?>
                  <table width="45%" border="0" cellspacing="0" cellpadding="0" align="right">
                    <tr>
                      <td>
                        <form name="form1" method="post" action="viewpsale.php?step=1">
                          <p><b><font face=Arial>Step 1 </font>- 选择要查询的产品</b></p>
                          <p>
                            <select name="pid">
<?
      $html='';
      while ($record=mysql_fetch_object($result))
        $html.='<option value="'.$record->pid.'">'.$record->pid." - ".$record->pname.'</option>';
      echo $html;
?>
                            </select>
                          </p>
                          <p>
                            <input type="submit" name="Submit" value="查 询">
                                  <a href=index2.php>返回首页</a> </p>
                        </form>
                      </td>
                    </tr>
                  </table>
<?
    }
  }
  else
  {
?>
<table width="100%" border="0" cellspacing="2" cellpadding="1">
                    <tr bgcolor="#000000">
                      <td>
                        <div align="center"><b><font color="#FFFFFF">产品ID</font></b></div>
                      </td>
                      <td>
                        <div align="center"><b><font color="#FFFFFF">产 品 名</font></b></div>
                      </td>
                      <td>
                        <div align="center"><b><font color="#FFFFFF">批发价</font></b></div>
                      </td>
                      <td>
                        <div align="center"><b><font color="#FFFFFF">零售价</font></b></div>
                      </td>
<?
    $str_sql="select distinct(SALETB.sast) as stid,stname from SALETB,STOREHOUSETB,SALERC where SALETB.sast=STOREHOUSETB.stid and SALERC.pid='$pid' and SALERC.said=SALETB.said;";
    $result=mysql_db_query($db,$str_sql,$link_id);
    if (!$result) html_error_exit('MySQL查询命令失败!');
    $n=0;
    $html='';
    while ($record=mysql_fetch_object($result))
    {
      $st[$n]=$record->stid;
      $html.='                      <td><div align="center"><b><font color="#FFFFFF">'.$record->stname.'</font></b></div></td>';
      $n++;
    }
    echo $html.'<td><div align="center"><b><font color="#FFFFFF">总 计</font></b></div></td>
    <td><div align="center"><b><font color="#FFFFFF">总销售额</font></b></div></td></tr>';

    $str_sql="select pname,pprice,sprice from PRODUCTTB where pid='$pid';";
    $result=mysql_db_query($db,$str_sql,$link_id);
    if (!$result) html_error_exit('MySQL查询命令失败!');
    $record=mysql_fetch_object($result);
    $html='                    <tr bgcolor="#EEEEEE">
                      <td>
                        <div align="center">'.$pid.'</font></b></div>
                      </td>
                      <td>'.$record->pname.'</td>
                      <td>'.$record->pprice.'</td>
                      <td>'.$record->sprice.'</td>';
    $total1=0;
    $total2=0;
    for ($i=0;$i<$n;$i++)
    {
      $str_sql="select sum(samount) as samount, sum(money) as money from SALERC,SALETB where SALERC.pid='$pid' and SALETB.sast='".$st[$i]."' and SALETB.said=SALERC.said group by SALETB.sast;";
      $result=mysql_db_query($db,$str_sql,$link_id);
      if (!$result) html_error_exit('MySQL查询命令失败!');
      $record=mysql_fetch_object($result);
      $html.='<td align=center>'.$record->samount.'</td>';
      $total1+=$record->samount;
      $total2+=$record->money;
    }
    $html.='<td>'.$total1.'</td><td>'.$total2.'</td></tr></table><div align=right><a href=viewpsale.php?step=0>查询另一个产品</a>   <a href=index2.php>返回首页</a></div>';
    echo $html;
  }
  @mysql_close($link_id);
?>
                </td>
              </tr>
              <tr>
                <td height="40">
                  <table width="100%" border="0" cellspacing="0" cellpadding="0" height="40">
                    <tr>
                      <td valign="bottom" align="right"><font face="Arial"><b>Powered
                        by <img src="images/viewpsale.php.gif" width="39" height="20" align="absmiddle">
                        &amp; <img src="images/mysql.gif" width="82" height="20" align="absmiddle"></b></font></td>
                      <td align="right" valign="bottom" width="200"><font face="Arial">&copy;
                        <a href="mailto:lonelyp@etang.com">Lonely Passenger</a>,2001<br>
                        All rights reserved!</font></td>
                    </tr>
                  </table>
                </td>
              </tr>
            </table>
          </td>
        </tr>
      </table>
    </td>
  </tr>
</table>
</body>
</html>
<?
  }
?>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -