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

📄 product_detail.php

📁 php模块设计。。。里面的模块很有学习价值
💻 PHP
字号:
<?
	include("db_conn.php");
	include("db_func.php");

	// 使用 JOIN 的语句将 product 及 class 结合起来 BEGIN
	$SQLStr = "SELECT product.*, class.* FROM product AS product ";
	$SQLStr .= "LEFT JOIN class AS class ON product.c_id = class.c_id WHERE p_id='$p_id'";
	$res = db_query($SQLStr);
	// 使用 JOIN 的语句将 product 及 class 结合起来 END

	// 取出 class 表中的字段值 BEGIN
	$SQLStr2 = "SELECT * FROM class";
	$res2 = db_query($SQLStr2);
	// 取出 class 表中的字段值 END

	if (db_num_rows($res)>0) // 判断查询结果是否有值
	{
	$row = db_fetch_array($res);
?>

<?
	include("up.htm"); // 外挂上方的功能栏
?>

<!------ 传给 product_process.php 文件 check 值为 upd ------>
<form name="form1" method="post" action="product_process.php?check=upd">
  <table width="770" border="1" cellpadding="0" cellspacing="0" align="center" bordercolor="#0000FF">
    <tr> 
      <td bgcolor="#FFFFCC"> 
        <table width="400" border="0" align="center">
          <tr> 
            <td width="60%" bgcolor="#9933FF" align="center"><font color="#FFFFFF">产品详细信息</font>
            </td>
            <td width="25%" bgcolor="#9966FF" align="center"><font color="#FFFFFF"><?=$row[p_id]?></font></td>
            <td width="10%" bgcolor="#9999FF">&nbsp;</td>
            <td width="3%" bgcolor="#9999FF">&nbsp;</td>
            <td width="2%" bgcolor="#99CCFF">&nbsp;</td>
          </tr>
	</table>
	<table width="770">
	  <tr>
            <td align="center"> 
              <input type="submit" name="submit" value="更改产品信息">
            </td>
	  </tr>
        </table>
        <table width="770" border="0" cellpadding="1" cellspacing="1" bgcolor="#99CCFF" bordercolor="#0000FF">
          <tr> 
            <td rowspan="4" width="135" bgcolor="#FFFFFF" valign="middle" align="center"> 
		<img src="<?=$row['p_pic']?>">
	        <input type="hidden" name="p_pic" value="<?=$row['p_pic']?>">
            </td>
            <td width="86" align="center">产品类别</td>
            <td width="209" align="left"> 
<?
 		$num = db_num_rows($res2);

		// 以下拉列表呈现类别的名称 BEGIN
                echo "<select name='c_id'>";
		echo "<option value='" . $row['c_id'] . "'>" . $row['c_name'] . "</option>";
		for ($i=0;$i<$num;$i++)
		{
		  $row2 = db_fetch_array($res2);
	          echo "<option value='" . $row2['c_id'] . "'>" . $row2['c_name'] . "</option>";
		}
                echo "</select>";
		// 以下拉列表呈现类别的名称 END
?>
		<input type="hidden" name="p_id" size="10" value="<?=$row['p_id']?>">
            </td>
            <td width="85" align="center">产品名称</td>
            <td width="201" align="left">
                <input type="text" name="p_name" size="22" value="<?=$row['p_name']?>">
            </td>
          </tr>
          <tr> 
            <td width="86" align="center">产品来源</td>
            <td width="209" align="left">
                <input type="text" name="p_source" size="15" value="<?=$row['p_source']?>">
            </td>
            <td width="85" align="center">产品连结</td>
            <td width="201" align="left">
                <input type="text" name="p_link" size="20" value="<?=$row['p_link']?>">
            </td>
          </tr>
          <tr>
            <td width="86" align="center">产品售价</td>
            <td width="209" align="left">
                <input type="text" name="p_price" size="8" value="<?=$row['p_price']?>">
            </td>
            <td width="85" align="center">产品成本</td>
            <td width="201" align="left">
                <input type="text" name="p_cost" size="8" value="<?=$row['p_cost']?>">
            </td>
          </tr>
          <tr>
            <td width="86" height="22" align="center">库存数量</td>
            <td width="209" height="22" align="left">
                <input type="text" name="p_numbers" size="8" value="<?=$row['p_numbers']?>">
            </td>
            <td width="85" height="22" align="center">进货日期</td>
            <td width="201" height="22" align="left">
                <input type="text" name="p_date" size="16" value="<?=$row['p_date']?>">
            </td>
          </tr>
          <tr>
            <td align="center"><input type="text" size="12" name="p_pic" value="<?=$row['p_pic']?>"></td>
            <td width="86" height="22" align="center">热门程度</td>
            <td width="209" height="22" align="left">
                <input type="text" name="p_hot" size="8" value="<?=$row['p_hot']?>">
            </td>
            <td width="85" height="22" align="center">是否推荐</td>
            <td width="201" height="22" align="left">
                <select name="p_commend">
<?
		if ($row['p_commend'] == 1)
		{
                  echo "<option value='1'>推荐</option>\n";
                  echo "<option value='0'>不推荐</option>\n";
		}
		else
		{
                  echo "<option value='0'>不推荐</option>\n";
                  echo "<option value='1'>推荐</option>\n";
		}
?>  
                </select>
            </td>
          </tr>
          <tr> 
            <td width="135" bgcolor="#FFFFFF" align="center"> 
              <select name="p_actival">
<?
		if ($row['p_actival'] == 1)
		{
                  echo "<option value='1'>上架中</option>\n";
                  echo "<option value='0'>产品下架</option>\n";
		}
		else
		{
                  echo "<option value='0'>下架中</option>\n";
                  echo "<option value='1'>产品上架</option>\n";
		}
?>
                </select>
            </td>
            <td colspan="4" align="center" bgcolor="#666666">
              <font color="#FFFFFF">已销售:<?=$row['p_sell']?></font></td>
          </tr>
        </table>
        <table width="770" border="0">
          <tr bgcolor="#99CCCC">
            <td align="center">产品信息</td>
            <td align="center">
                <textarea name="p_info" cols="50" rows="10"><?=$row['p_info']?></textarea>
            </td>
          </tr>
        </table>
      </td>
    </tr>
  </table>
</form>
<?
}
else
	{
		echo "<script>";
		echo "alert(\"无此产品\");";
		echo "</script>";
		echo "<body onload = \"window.close();\">";
	}
?>

⌨️ 快捷键说明

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