PHP

当前位置:首页 > 后端 > PHP

ajax 模板

<?php define(&#39;ALLOWGUEST&#39;,true); require &#39;../source/core/run.php&#39;; $types = $_POST[&#39;types&#39;]; $table...
<?php
	define('ALLOWGUEST',true);

	require '../source/core/run.php';

	$types = $_POST['types'];

	$table = $_POST['table'];

	$firstcid = $_POST['firstcid'];


	if($table == 'product'){

			// 初加载
			if($types == 1){
				$cid = $_POST['cid'];
				if(empty($cid)){
					$sql1  = "SELECT * FROM ".DB_PREFIX.$table ." WHERE flag=1 ORDER BY orders ASC";
				}else{
					$sql1  = "SELECT * FROM ".DB_PREFIX.$table ." WHERE flag=1 AND cid=$cid ORDER BY orders ASC";
				}
				$data1 = $db->getall($sql1);

				if(!empty($data1)){
					$sayList ="";
					foreach ($data1 as $key => $val) {
		    			$url = PATH_URL.'product/'.$val['id'].".html";
		    			$img = "<img src=".$val['uploadfiles']." alt=".$val['title']." />";
		    			$string = strip_tags($val['content']);
						$string = preg_replace ('/\n/is', '', $string);
						$string = preg_replace ('/ | /is', '', $string);
						$string = preg_replace ('/&nbsp;/is', '', $string);
						$content = mb_substr($string, 0, 65)."...";
		    			$sayList.="<li>";
		    			$sayList.="<a href=".$url." title=".$val['title']." class='img'>";
		    			$sayList.="".$img."";
		    			$sayList.="</a>";
						$sayList.="<h3>";
						$sayList.="<a href=".$url." title=".$val['title'].">";
						$sayList.="".$val['title']."";
						$sayList.="</a>";
						$sayList.="</h3>";
						$sayList.="</li>";
					}
					echo '{"status":"1","info":"'.$sayList.'"}';
				}else{
					echo '{"status":"0"}';
				}


			// 点击属性
			}else if($types == 2){
				$cid = $_POST['cid'];

				if(empty($cid)){
					$sql1  = "SELECT * FROM ".DB_PREFIX. $table ." WHERE flag=1 ORDER BY orders ASC";

				}else{
					$sql1  = "SELECT * FROM ".DB_PREFIX. $table ." WHERE flag=1 AND cid=$cid ORDER BY orders ASC";

				}

				$data1 = $db->getall($sql1);
				if(!empty($data1)){
					$sayList ="";
					foreach ($data1 as $key => $val) {
						$url = PATH_URL.'product/'.$val['id'].".html";
		    			$img = "<img src=".$val['uploadfiles']." alt=".$val['title']." />";
		    			$string = strip_tags($val['content']);
						$string = preg_replace ('/\n/is', '', $string);
						$string = preg_replace ('/ | /is', '', $string);
						$string = preg_replace ('/&nbsp;/is', '', $string);
						$content = mb_substr($string, 0, 70)."...";
		    			$sayList.="<li>";
		    			$sayList.="<a href=".$url." title=".$val['title']." class='img'>";
		    			$sayList.="".$img."";
						$sayList.="</a>";
						$sayList.="<h3>";
						$sayList.="<a href=".$url." title=".$val['title'].">";
						$sayList.="".$val['title']."";
						$sayList.="</h3>";
						$sayList.="</a>";
						$sayList.="</li>";
					}
					echo '{"status":"1","info":"'.$sayList.'"}';
				}else{
					echo '{"status":"0"}';
				}
			}




		

	}else if($table == 'news'){


			// 初加载
			if($types == 1){
				$cid = $_POST['cid'];
				if(empty($cid)){
					$sql1  = "SELECT * FROM ".DB_PREFIX.$table ." WHERE flag=1 ORDER BY orders ASC";
				}else{
					$sql1  = "SELECT * FROM ".DB_PREFIX.$table ." WHERE flag=1 AND cid=$cid ORDER BY orders ASC";
				}
				$data1 = $db->getall($sql1);

				if(!empty($data1)){
					$sayList ="";

					foreach ($data1 as $key => $val) {
		    			$url = PATH_URL.'news/'.$val['id'].".html";
		    			$img = "<img src=".$val['uploadfiles']." alt=".$val['title']." />";
		    			$string = strip_tags($val['content']);
						$string = preg_replace ('/\n/is', '', $string);
						$string = preg_replace ('/ | /is', '', $string);
						$string = preg_replace ('/&nbsp;/is', '', $string);
						$content = mb_substr($string, 0, 200)."...";
						$formattedDate = date("Y-m-d H:i:s", $val['timeline']);

		    			$sayList.="<li>";
		    			$sayList.="<a href=".$url." title=".$val['title'].">";
	    				$sayList.="<div class='tit'>";
	    				$sayList.="<h3>";
	    				$sayList.="".$val['title']."";
	    				$sayList.="</h3>";
	    				$sayList.="<div class='date'>";
	    				$sayList .= "".$formattedDate."";
	    				$sayList.="</div>";
	    				$sayList.="</div>";
	    				$sayList.="<div class='info'>";
	    				$sayList.="".$content."";
	    				$sayList.="</div>";
	    				$sayList.="<div class='more'>";
	    				$sayList.="<span>More +</span>";
	    				$sayList.="</div>";
		    			$sayList.="</a>";
						$sayList.="</li>";
					}
					echo '{"status":"1","info":"'.$sayList.'"}';
				}else{
					echo '{"status":"0"}';
				}


			// 点击属性
			}else if($types == 2){
				$cid = $_POST['cid'];

				if(empty($cid)){
					$sql1  = "SELECT * FROM ".DB_PREFIX. $table ." WHERE flag=1 ORDER BY orders ASC";
				}else{
					$sql1  = "SELECT * FROM ".DB_PREFIX. $table ." WHERE flag=1 AND cid=$cid ORDER BY orders ASC";
				}

				$data1 = $db->getall($sql1);
				if(!empty($data1)){
					$sayList ="";
					foreach ($data1 as $key => $val) {
						$url = PATH_URL.'news/'.$val['id'].".html";
		    			$img = "<img src=".$val['uploadfiles']." alt=".$val['title']." />";
		    			$string = strip_tags($val['content']);
						$string = preg_replace ('/\n/is', '', $string);
						$string = preg_replace ('/ | /is', '', $string);
						$string = preg_replace ('/&nbsp;/is', '', $string);
						$content = mb_substr($string, 0, 200)."...";
						$formattedDate = date("Y-m-d H:i:s", $val['timeline']);

		    			$sayList.="<li>";
		    			$sayList.="<a href=".$url." title=".$val['title'].">";
	    				$sayList.="<div class='tit'>";
	    				$sayList.="<h3>";
	    				$sayList.="".$val['title']."";
	    				$sayList.="</h3>";
	    				$sayList.="<div class='date'>";
	    				$sayList .= "".$formattedDate."";
	    				$sayList.="</div>";
	    				$sayList.="</div>";
	    				$sayList.="<div class='info'>";
	    				$sayList.="".$content."";
	    				$sayList.="</div>";
	    				$sayList.="<div class='more'>";
	    				$sayList.="<span>More +</span>";
	    				$sayList.="</div>";
		    			$sayList.="</a>";
						$sayList.="</li>";
					}
					echo '{"status":"1","info":"'.$sayList.'"}';
				}else{
					echo '{"status":"0"}';
				}
			}



	}else if($table == 'case'){

			if($firstcid == 1){

				// 初加载
				if($types == 1){
					$cid = $_POST['cid'];
					if(empty($cid)){
						$sql1  = "SELECT * FROM ".DB_PREFIX.$table ." WHERE flag=1 ORDER BY orders ASC";
					}else{
						$sql1  = "SELECT * FROM ".DB_PREFIX.$table ." WHERE flag=1 AND cid=$cid ORDER BY orders ASC";
					}
					$data1 = $db->getall($sql1);

					if(!empty($data1)){
						$sayList ="";
						foreach ($data1 as $key => $val) {
			    			$url = PATH_URL.'case/'.$val['id'].".html";
			    			$img = "<img src=".$val['uploadfiles']." alt=".$val['title']." />";
			    			$string = strip_tags($val['content']);
							$string = preg_replace ('/\n/is', '', $string);
							$string = preg_replace ('/ | /is', '', $string);
							$string = preg_replace ('/&nbsp;/is', '', $string);
							$content = mb_substr($string, 0, 65)."...";

							$string2 = strip_tags($val['case11']);
							$string2 = preg_replace ('/\n/is', '', $string2);
							$string2 = preg_replace ('/ | /is', '', $string2);
							$string2 = preg_replace ('/&nbsp;/is', '', $string2);
							$case11 = mb_substr($string2, 0, 200)."...";


			    			$sayList.="<li class='flex_11'>";
		    				$sayList.="<div class='img_xx'>";
			    			$sayList.="<a href=".$url." title=".$val['title']." class='img'>";
			    			$sayList.="".$img."";
			    			$sayList.="</a>";
			    			$sayList.="</div>";
			    			$sayList.="<div class='d_cm'>";
			    			$sayList.="<h3>";
							$sayList.="<a href=".$url." title=".$val['title'].">";
							$sayList.="".$val['title']."";
							$sayList.="</a>";
							$sayList.="</h3>";
							$sayList.="<h4>";
							$sayList.="".$case11."";
							$sayList.="</h4>";
							$sayList.="<div class='more_kv'>";
							$sayList.="<a href=".$url." title=".$val['title'].">";
							$sayList.="查看更多>>";
							$sayList.="</a>";
							$sayList.="</div>";
			    			$sayList.="</div>";
							$sayList.="</li>";
						}
						echo '{"status":"1","info":"'.$sayList.'"}';
					}else{
						echo '{"status":"0"}';
					}


				// 点击属性
				}else if($types == 2){
					$cid = $_POST['cid'];

					if(empty($cid)){
						$sql1  = "SELECT * FROM ".DB_PREFIX. $table ." WHERE flag=1 ORDER BY orders ASC";
					}else{
						$sql1  = "SELECT * FROM ".DB_PREFIX. $table ." WHERE flag=1 AND cid=$cid ORDER BY orders ASC";
					}

					$data1 = $db->getall($sql1);
					if(!empty($data1)){
						$sayList ="";
						foreach ($data1 as $key => $val) {
							$url = PATH_URL.'case/'.$val['id'].".html";
			    			$img = "<img src=".$val['uploadfiles']." alt=".$val['title']." />";
			    			$string = strip_tags($val['content']);
							$string = preg_replace ('/\n/is', '', $string);
							$string = preg_replace ('/ | /is', '', $string);
							$string = preg_replace ('/&nbsp;/is', '', $string);
							$content = mb_substr($string, 0, 70)."...";

							$string2 = strip_tags($val['case11']);
							$string2 = preg_replace ('/\n/is', '', $string2);
							$string2 = preg_replace ('/ | /is', '', $string2);
							$string2 = preg_replace ('/&nbsp;/is', '', $string2);
							$case11 = mb_substr($string2, 0, 200)."...";
							
			    			$sayList.="<li class='flex_11'>";
		    				$sayList.="<div class='img_xx'>";
			    			$sayList.="<a href=".$url." title=".$val['title']." class='img'>";
			    			$sayList.="".$img."";
			    			$sayList.="</a>";
			    			$sayList.="</div>";
			    			$sayList.="<div class='d_cm'>";
			    			$sayList.="<h3>";
							$sayList.="<a href=".$url." title=".$val['title'].">";
							$sayList.="".$val['title']."";
							$sayList.="</a>";
							$sayList.="</h3>";
							$sayList.="<h4>";
							$sayList.="".$case11."";
							$sayList.="</h4>";
							$sayList.="<div class='more_kv'>";
							$sayList.="<a href=".$url." title=".$val['title'].">";
							$sayList.="查看更多>>";
							$sayList.="</a>";
							$sayList.="</div>";
			    			$sayList.="</div>";
							$sayList.="</li>";
						}
						echo '{"status":"1","info":"'.$sayList.'"}';
					}else{
						echo '{"status":"0"}';
					}
				}


			}else{


				// 初加载
				if($types == 1){
					$cid = $_POST['cid'];
					if(empty($cid)){
						$sql1  = "SELECT * FROM ".DB_PREFIX.$table ." WHERE flag=1 ORDER BY orders ASC";
					}else{
						$sql1  = "SELECT * FROM ".DB_PREFIX.$table ." WHERE flag=1 AND cid=$cid ORDER BY orders ASC";
					}
					$data1 = $db->getall($sql1);

					if(!empty($data1)){
						$sayList ="";
						foreach ($data1 as $key => $val) {
			    			$url = PATH_URL.'case/'.$val['id'].".html";
			    			$img = "<img src=".$val['uploadfiles']." alt=".$val['title']." />";
			    			$string = strip_tags($val['content']);
							$string = preg_replace ('/\n/is', '', $string);
							$string = preg_replace ('/ | /is', '', $string);
							$string = preg_replace ('/&nbsp;/is', '', $string);
							$content = mb_substr($string, 0, 65)."...";
			    			$sayList.="<li>";
		    				$sayList.="<div class='abgg_c'>";
			    			$sayList.="<a href=".$val['description']." title=".$val['title']." data-fancybox auotoSize='false' data-type='iframe' data-width='800' data-height='500'>";
			    			$sayList.="".$img."";
			    			$sayList.="</a>";
			    			$sayList.="</div>";
							$sayList.="<h3>";
							$sayList.="<a href=".$url." title=".$val['title'].">";
							$sayList.="".$val['title']."";
							$sayList.="</a>";
							$sayList.="</h3>";
							$sayList.="</li>";
						}
						echo '{"status":"1","info":"'.$sayList.'"}';
					}else{
						echo '{"status":"0"}';
					}


				// 点击属性
				}else if($types == 2){
					$cid = $_POST['cid'];

					if(empty($cid)){
						$sql1  = "SELECT * FROM ".DB_PREFIX. $table ." WHERE flag=1 ORDER BY orders ASC";
					}else{
						$sql1  = "SELECT * FROM ".DB_PREFIX. $table ." WHERE flag=1 AND cid=$cid ORDER BY orders ASC";
					}

					$data1 = $db->getall($sql1);
					if(!empty($data1)){
						$sayList ="";
						foreach ($data1 as $key => $val) {
							$url = PATH_URL.'case/'.$val['id'].".html";
			    			$img = "<img src=".$val['uploadfiles']." alt=".$val['title']." />";
			    			$string = strip_tags($val['content']);
							$string = preg_replace ('/\n/is', '', $string);
							$string = preg_replace ('/ | /is', '', $string);
							$string = preg_replace ('/&nbsp;/is', '', $string);
							$content = mb_substr($string, 0, 70)."...";
			    			$sayList.="<li>";
		    				$sayList.="<div class='abgg_c'>";
			    			$sayList.="<a href=".$val['description']." title=".$val['title']." data-fancybox auotoSize='false' data-type='iframe' data-width='800' data-height='500'>";
			    			$sayList.="".$img."";
			    			$sayList.="</a>";
			    			$sayList.="</div>";
							$sayList.="<h3>";
							$sayList.="<a href=".$url." title=".$val['title'].">";
							$sayList.="".$val['title']."";
							$sayList.="</a>";
							$sayList.="</h3>";
							$sayList.="</li>";
						}
						echo '{"status":"1","info":"'.$sayList.'"}';
					}else{
						echo '{"status":"0"}';
					}
				}



			}

			




	}

	


	


?>


上一篇:新闻分类名称后面显示该分类下的新闻数量

下一篇:已经是最后一篇

相关内容

文章评论

表情

共 0 条评论,查看全部
  • 这篇文章还没有收到评论,赶紧来抢沙发吧~