php:
相册管理页面*{ font-family:微软雅黑}
//1.创建数据库
$con = mysql_connect("localhost","root","root");
//2.验证
if($con){
//echo "数据库连接成功
";
}else{
echo "数据库连接失败
";
}
//3.指定数据库
mysql_select_db("sgjydb",$con);
//4.读取数据
mysql_query("set names utf8");//指定字符编码
$query = "select * from imgclasstab";
$result = mysql_query($query);
if($result){
//echo "查找数据成功
";
}else{
echo "查找数据失败
".mysql_errno();
}
?>
while ($list = mysql_fetch_array($result)){
//echo "id=".$list["imgClassId"];
$imgClassId = 1;
echo '
echo '';
//echo "当前的图地址:".$list["imgClassCoverUrl"];
//$tjquery = "select imgClassId,imgClassDescription from imgclasstab where imgClassCoverUrl=".$list["imgClassCoverUrl"];
//$tjresult = mysql_query($tjquery);
//$tjId = $list["imgClassId"];
echo '
echo '
'.$list["imgClassCName"].'
';echo '
'.$list["imgClassDescription"].'
';
echo '查看更多
';echo '';
echo '';
}
?>
$(document).ready(function(){
$("#addXcBtn").click(function(){
alert("开始创建");
$.ajax({
url:'php/addXc.php',
type:'post',
data:{//键值对中:前者键是input的name键值,后者值为input的value值
"addXcBtn":$("#addXcBtn").val(),
"classCover":$("#classCover").attr("name"),
//"classCover":$("#classCover").val(),
"className":$("#className").val(),
"classDesciription":$("#classDesciription").val(),
},
success:function(data){
console.log("data="+data);
if(data=="创建成功"){
alert("创建成功");
}else{
alert("创建失败");
}
}
})
});
});
php:
$bb = 'begin';
$xcCover = $_POST["classCover"];
/*echo "相册封面:".$xcCover."
";
$aa = $_FILES["'".$xcCover."'"]['name'];
echo "相册封面名称:".$aa."
";*/
$aa = $_FILES["'".$xcCover."'"]['type'];
echo "相册封面类型:".$aa."
";
$scName = $_POST["className"];
echo "相册名称:".$scName."
";
$xcDes = $_POST["classDesciription"];
echo "相册描述:".$xcDes."
";
/*$addXcBtn = $_POST["addXcBtn"];
echo "获取到相册封面的name是:".$addXcBtn."
";
$xcCover = $_POST["classCover"];
echo "获取到相册封面的name是:".$xcCover."
";
*/
/*$aa = 'ww';
if($aa == 'w'){
echo "创建成功";
}else{
echo "创建失败";
}
$aa = 'begin';
$addXcBtn = $_POST["addXcBtn"];
echo "获取的提交按钮的value是:".$addXcBtn."
";
$xcCover = $_POST["classCover"];
echo "封面value是:".$xcCoverName;
$xcCoverName = $_FILES["'".$xcCover."'"]['name'];
echo "封面名称是:".$xcCoverName;
*/
if($bb == 'w'){
echo "创建成功";
}else{
echo "创建失败";
}
?>