电子商务管理员协助表单提交

时间:2014-08-14 16:18:17

标签: php

你好,每个人一周,我一直在尝试2为我的电子商务商店创建自己的管理面板,我在面板的1个部分遇到一点麻烦我想要的任务逻辑2显示所有的产品,尺寸,之前的表格中的颜色有3个下降然后完成之后我可以为产品选择许多选项示例产品1有3种颜色和3种尺寸产品1红蓝绿小,大,xlarge。在提交它转到新表调用product_attribute然后在商店页面上,客户可以选择产品源代码的大小和颜色在这里

<?php
// Check for a product
if (isset($_POST['products'])){
//do something this block is where im having the trouble
$size = $_POST['size'];
$colors = $_POST['colors'];$newproduct = array(
"products" => array("size" => "", "colors")); $sql = mysql_query("INSERT INTO product_attribute (product_id, size_id, color_id) 
    VALUES('$product_id','$size_id','$color_id'") or die (mysql_error());}
?>

<?php   
// Need the available sizes:
$sizeList= '<select name="size[]" multiple= "multiple" size="3">';
$sql = mysql_query("SELECT size_name FROM size");
$result = mysql_query($sql);
while ($row = mysql_fetch_array($sql)) {$size_name=  $row["size_name"];
$sizeList .='<option value="'.$row['size_name'].'">'.$row['size_name'].'</option>';}
$sizeList .= '</select>';
// Need the available colors:       
$colorList= '<select name="colors[]" multiple= "multiple" size="3">';
$sql = mysql_query("SELECT color_name FROM colors");
$result = mysql_query($sql);
while ($row = mysql_fetch_array($sql)) {
$color_name=  $row["color_name"];
$colorList .='<option value="'.$row['color_name'].'">'.$row['color_name'].'</option>';}
$colorList .= '</select>';
?>
<!DOCTYPE HTML>
<html><!-- InstanceBegin template="/Templates/admin_template.dwt" odeOutsideHTMLIsLocked="false" -->
<head>
<meta charset="utf-8">
<!-- InstanceBeginEditable name="doctitle" -->
<title>Product Option</title>
<!-- InstanceEndEditable -->
<link rel="stylesheet"href="style/style.css" type="text/css" media="screen">
<link rel="stylesheet"href="style/style.css" type="text/css" media="print">
<!-- InstanceBeginEditable name="head" -->
<!-- InstanceEndEditable -->
</head>

<body>
<div id="wrapper">
<!-- InstanceBeginEditable name="header" -->
<div id="header"><img src="../images/dump/admin-logo[1].gif" alt="Insert Logo Here"   name="Insert_logo" width="221" height="135" id="Insert_logo" style="display:block; background: #CCC; border-top-right-radius: 6px;
border-bottom-right-radius: 6px;
box-shadow: 8px rgba(2, 2, 2, 2.15);
-webkit-box-shadow: 0px 0px 8px rgba(2, 2, 2, 2.2);" /> 
<!-- end .header --></div>
<!-- InstanceEndEditable -->

<!-- InstanceBeginEditable name="leftside" -->
<div id="leftside">
<ul class="nav">
<li><a href="inventorylist.php">Add a Product</a></li>
<li><a href="inventory_product_attribute.php"> Add a Products Options</a></li>
<li><a href="inventorylist.php">Edit a Product</a></li>    
<li><a href="image_upload_script.php">Upload files</a></li>
<li><a href="#">Edit Pages</a></li>
<li><a href="#">Add an Admin User</a></li>
<li><a href="storescript_includes/logout.php" title="Logout">Logout.</a></li>
<li><a href="../index.html">Home</a></li>
</ul>
<p>&nbsp;</p>
<!-- end .sidebar1 --></div>
<!-- InstanceEndEditable -->
<!-- InstanceBeginEditable name="Contentedit" -->
<div id="content2">

<div align="left" style="margin-right:32px;">   ADMIN USER: <?php echo $manager; ?></div>
<h1>Product attributes</h1>
<form action="inventory_product_attribute.php" method="post" name="myform">
<fieldset><legend>Fill out the form to add specific  products to the site.(hold "Ctrl" key o select multiple):</legend>
<ol>    
<li><label for="products"><strong>Product option </strong></label>


<?php
//$sql="SELECT name,id FROM student"; 
$sql=mysql_query("SELECT product_name,product_id FROM products order by product_name"); 
/* You can add order by clause to the sql statement if the names are to be displayed in alphabetical order */
echo  '<select name="products[]">'; // list box select command
while ($row = mysql_fetch_array($sql)) {//Array or records stored in $row
echo '<option value="'.$row['product_id'].'">'.$row['product_name'].'</option>';
/* Option values are added by looping through the array */ 
}
echo "</select>";// Closing of list box
?>  
</li>   
<br />
<br />
<br />
<li><h1> Sizes </h1>
<?php echo $sizeList; ?>
</li>
<br />
<li>
<h1> Colors</h1>
<?php echo $colorList; ?>
</li>
<br />
<br />
<li><input name="myBtn" type="submit" /></li>
</ol>
</fieldset>
</form> 
</div>

1 个答案:

答案 0 :(得分:0)

一种选择是将所有数据发送到页面,然后use a JQuery plugin to filter it