我有两张桌子
$table1 = ("10", "20", "30", "40");
$table2 = ("a", "b", "c", "d");
现在我想要将这两个表组合起来。这是我的SQL CODE
$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,
我很难让你了解我的问题,希望你能理解并回答我的问题。
抱歉,我的英语不好。我为任何错误道歉。
答案 0 :(得分:0)
我认为你应该在你的sql语句中使用group by 你可以在这里阅读“分组依据”http://www.w3schools.com/sql/sql_groupby.asp