篩選A資料表b沒有的

edited 八月 2014 in PHP新手區
<?php session_start();?>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<?php include ('db.php');?>
<html>
<head>
</head>
<body>
<form name="R4" method="post" action="addshop.php">
<?php
	$user = '1';
	$town =$_POST['F_I_CNo'];
	$shop = $_POST['shop'];
	$result = mysql_query("select * from city where AutoNo = '$town'");
	$towns = mysql_fetch_row($result);
	$result1 =mysql_query("select * from shoplist where area = '$towns[0]'");
	$shops = mysql_fetch_row($result1);	
	$result3 = mysql_query("select * from shop_company where company_ID='$user'");
	$shopnum =mysql_query("select * from shoplist ");
	$shopsum=mysql_num_rows($result3);
	$shopsums=mysql_num_rows($shopnum);
	$shps=$shopsums-$shopsum;
	
	//$result5= mysql_query("select * from shoplist where ")
	
	//$row1 = mysql_fetch_row($result2)
	$result2 = mysql_query("select * from shoplist where shopname LIKE '%$shop%' && area ='$towns[0]' ");
	
	if($town !=null){
	//	if($shop != null){
	//while($row1 = mysql_fetch_row($result4)){
	$count =0;
	while($count < $shps){?>
	<?php  
	$notshow = mysql_fetch_row($result3);
	$result4 =mysql_query("select * from shoplist where shopID != '$notshow[1]' ");
	$row1 = mysql_fetch_row($result4);
	?>
		<input type="hidden" name="shopsn" style='width:100px;' value="<?php echo "$row1[0]"?>"><br>
		<input type="checkbox" name="check_shop[]" value="<?php echo "$row1[0]" ?>">
		<label for="$row1[0]"><?php echo "$row1[0]"."$row1[3]"."&nbsp"."$row1[2]"."<br>";?>
		</label>
		
	<?php $count++; } 
/*		echo "搜尋資訊有誤";
		echo "請輸入店名查詢";
		echo '<meta http-equiv=REFRESH CONTENT=1;url=queryshop.php>';*/
	}else{
		echo "請先選擇縣市";
		echo '<meta http-equiv=REFRESH CONTENT=1;url=queryshop.php>';
	}
	
	
	?>

	<p><input type="submit" name="addshp" value="新增店家"></p>
</form>	
<form method="post" name="R8" action = "queryshop.php">
<p><input type="submit" name="b2" value="回上一頁"></p>
</form>		
</body>
</html>	
		

目前只能篩選出A資料表中B資料表有的,可是我想要將A資料表的資料在B資料表的資料中比對完後,將沒有一致的顯示出來
(希望可以不要用的JOIN)~

評論

  • 避免使用join是為了降低DB 的 cpu loading?
    以前有這樣被要求過,把所有資料拉倒 php 中作 select , 排序 , 與統計.
    為了滿足這要求,做了一批array 處理funtion 來模擬 sql 的 join select 結果
    精神是把所有的 recordset 都弄成陣列
    再用陣列函式去處理
    比如
    篩選A資料表B沒有的
    1. 尋訪 array A
    2. 比較 array A 與 array B 要比對的欄位 , 如果 不等於 加資料結果陣列

    不過,日後都不這麼幹了,因為硬體便宜了
Sign In or Register to comment.