這篇文章主要介紹了php如何實(shí)現(xiàn)商品添加功能并寫入數(shù)據(jù)庫(kù)的相關(guān)知識(shí),內(nèi)容詳細(xì)易懂,操作簡(jiǎn)單快捷,具有一定借鑒價(jià)值,相信大家閱讀完這篇php如何實(shí)現(xiàn)商品添加功能并寫入數(shù)據(jù)庫(kù)文章都會(huì)有所收獲,下面我們一起來(lái)看看吧。
創(chuàng)新互聯(lián)主營(yíng)漢源網(wǎng)站建設(shè)的網(wǎng)絡(luò)公司,主營(yíng)網(wǎng)站建設(shè)方案,重慶APP開(kāi)發(fā),漢源h5成都微信小程序搭建,漢源網(wǎng)站營(yíng)銷推廣歡迎漢源等地區(qū)企業(yè)咨詢
數(shù)據(jù)庫(kù)表
寫入數(shù)據(jù)的代碼
include("conn/conn.php");
header ( "Content-type: text/html; charset=gb2312" );
?>
添加商品
添加商品
保存寫入數(shù)據(jù)的處理文件
header ( "Content-type: text/html; charset=gb2312" ); //設(shè)置文件編碼格式
include("conn/conn.php");
if(is_numeric($_POST['shichangjia'])==false || is_numeric($_POST['huiyuanjia'])==false)
{
echo "";
exit;
}
if(is_numeric($_POST['shuliang'])==false)
{
echo "";
exit;
}
$mingcheng=$_POST['mingcheng'];
$nian=$_POST['nian'];
$yue=$_POST['yue'];
$ri=$_POST['ri'];
$shichangjia=$_POST['shichangjia'];
$huiyuanjia=$_POST['huiyuanjia'];
$typeid=$_POST['typeid'];
$dengji=$_POST['dengji'];
$xinghao=$_POST['xinghao'];
$pinpai=$_POST['pinpai'];
$tuijian=$_POST['tuijian'];
$shuliang=$_POST['shuliang'];
$upfile=$_POST['upfile'];
if(ceil(($huiyuanjia/$shichangjia)*100)<=80)
{
$tejia=1;
}
else
{
$tejia=0;
}
function getname($exname){
$dir = "upimages/";
$i=1;
if(!is_dir($dir)){
mkdir($dir,0777);
}
while(true){
if(!is_file($dir.$i.".".$exname)){
$name=$i.".".$exname;
break;
}
$i++;
}
return $dir.$name;
}
$exname=strtolower(substr($_FILES['upfile']['name'],(strrpos($_FILES['upfile']['name'],'.')+1)));
$uploadfile = getname($exname);
move_uploaded_file($_FILES['upfile']['tmp_name'], $uploadfile);
if(trim($_FILES['upfile']['name']!=""))
{
$uploadfile="admin/".$uploadfile;
}
else
{
$uploadfile="";
}
$jianjie=$_POST['jianjie'];
$addtime=$nian."-".$yue."-".$ri;
mysqli_query($conn,"insert into tb_shangpin(mingcheng,jianjie,addtime,dengji,xinghao,tupian,typeid,shichangjia,huiyuanjia,pinpai,tuijian,shuliang,cishu)values('$mingcheng','$jianjie','$addtime','$dengji','$xinghao','$uploadfile','$typeid','$shichangjia','$huiyuanjia','$pinpai','$tuijian','$shuliang','0')");
echo "";
?>
關(guān)于“php如何實(shí)現(xiàn)商品添加功能并寫入數(shù)據(jù)庫(kù)”這篇文章的內(nèi)容就介紹到這里,感謝各位的閱讀!相信大家對(duì)“php如何實(shí)現(xiàn)商品添加功能并寫入數(shù)據(jù)庫(kù)”知識(shí)都有一定的了解,大家如果還想學(xué)習(xí)更多知識(shí),歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道。