存储部分
include("conn.php");
$number=$_POST['number'];
$itemname=$_POST['itemname'];
$price=$_POST['price'];
$meas=$_POST['meas'];
$picture=$_POST['picture'];
$packing=$_POST['packing'];
$material=$_POST['material'];
$addtime=$_POST['addtime'];
$name=$_FILES['picture']['name'];
$picture=$_FILES['picture']['tmp_name'];
$fp=fopen($picture,'r');
$data=addslashes(fread($fp,filesize($picture)));
$sql="insert into product(number,meas,itemname,addtime,picture,packing,price,material)values
('$number','meas','$itemname','$addtime','$picture','$packing','$price','$material')";
mysql_query($sql,$conn) or die("插入数据失败:".mysql_error());
mysql_close($conn);
if($_FILES['picture']['error']>0){
echo "上传出错"; }
else {
echo "上传成功";
}//From J.L
print_r($_POST);exit;
?>
显示部分
$sql=mysql_query("select * from product where price!=0 order by addtime desc limit 12,100");
//按price的值调用
$info=mysql_fetch_array($sql);
if(empty($info)){
echo "No product";
}
else{
?>
有什么疑问?当然可以保存路径.图片上传到服务器后,把存放图片的路径存到数据库里面.