2013-12-14 48 views
1

我有兩個表取兩個表合併(未顯示想要的結果)

$table1 = ("10", "20", "30", "40"); 
$table2 = ("a", "b", "c", "d"); 

現在我想取這兩個表結合。這裏是我的SQL代碼

$StatementOne = $_POST['catogry']."edb"; 
$StatementTwo = "SELECT* FROM ".$_POST['catogry']."ior"; 

$sql=mysqli_query($con," ".$StatementTwo." INNER JOIN ".$StatementOne." 
ON (".$_POST['catogry']."edb.ImportedItemDescriptionPartName = ".$_POST['catogry']."ior.Make 
AND ".$_POST['catogry']."ior.Vehicle = ".$_POST['catogry']."edb.VehicleModel) 
WHERE Vehicle='".$_POST['vehicle']."' AND Make='".$_POST['meterial']."' 
")or die ('Invalid Query:'. mysqli_error($con)); 

這是我的PHP代碼

while ($row =mysqli_fetch_array($sql)) 

{echo "<form action='edit-entriy.php?id=" . $row['EDBQuotaID'] . "' method='post'  enctype='multipart/form-data' name='myForm'><tr>";echo "<div style=' clear:both;'><div class='programing-page-width'><div class='mysqldata_fetch'><input type='submit' name='EDIT' value='Edit'></div>"; 
$post="list"; 
$checkboxes = (isset($_POST[$post]) ? $_POST[$post] : array()); 
foreach($checkboxes as $value) 
{ 
if ($value == 1) 
{echo"<div class='mysqldata_fetch'>". $row['PralSerial'] ."</div>";} 

if ($value == 2) 
{echo"<div class='mysqldata_fetch'>". $row['EDBQuotaID'] ."</div>";} 

if ($value == 3) 
{echo"<div class='mysqldata_fetch'>". $row['Grade'] ."</div>";} 

if ($value == 4) 
{echo"<div class='mysqldata_fetch'>". $row['ImportedItemDescriptionPartName'] ." </div>";} 

if ($value == 5) 
{echo"<div class='mysqldata_fetch'>". $row['ManufacturedPartName'] ."</div>";} 

if ($value == 6) 
{echo"<div class='mysqldata_fetch'>". $row['Vehicle'] ."</div>";} 

if ($value == 7) 
{echo"<div class='mysqldata_fetch'>". $row['HSCode'] ."</div>";} 

if ($value == 8) 
{echo"<div class='mysqldata_fetch'>". $row['NoofUnitsAnnum'] ."</div>";} 

if ($value == 9) 
{echo"<div class='mysqldata_fetch'>". $row['TotalApprovedQuantity'] ."</div>";} 

if ($value == 10) 
{echo"<div class='mysqldata_fetch'>". $row['UnitsAnnum'] ."</div>";} 

if ($value == 11) 
{echo"<div class='mysqldata_fetch'>". $row['AsCalculation'] ."</div>";} 

if ($value == 12) 
{echo"<div class='mysqldata_fetch'>". $row['SNo'] ."</div>";} 

if ($value == 13) 
{echo"<div class='mysqldata_fetch'>". $row['Make'] ."</div>";} 

} 

現在我已經得到的結果是這樣的

a - 10, 
b - 10, 
c - 10, 
d - 10, 
a - 20, 
b - 20, 
c - 20, 
d - 20, 
a - 30, 
b - 30, 
c - 30, 
d - 30, 
a - 40, 
b - 40, 
c - 40, 
d - 40, 

這不是一個結果是我想要的。它應該是這樣的。

a - 10, 
b - 20, 
c - 30, 
d - 40, 

這是接力難以讓我理解我的問題希望你能理解並回答我的問題。

對不起,我英語不好。我爲任何錯誤道歉。

回答

相關問題