我的数据库如何获得独特的价值在数组中的PHP
Tables_sup |
+------------------+
| supid |
scompany |
| scategory |
| smarket |
|
我的PHP代码
<?php
require_once 'DBConnect.php';
$con = mysqli_connect("localhost","gb","123");
if (!$con) {
die('Could not connect: ' . mysqli_error());
}
mysqli_select_db($con,"test_database");
$sql=mysqli_query($con,'SELECT DISTINCT sup.supid,sup.smarket FROM sup order by supid desc');
$i=0;
$dyn_table='<table border="1" cellpadding="10">';
while($row=mysqli_fetch_array($sql)){
$supid = $row["supid"];
$smarket = $row["smarket"];
if ($i%5==0){
$dyn_table.='<tr><td>'.$smarket. '<td>';
}else{
$dyn_table.='<td>'.$smarket. '<td>';
}
$i++;
}
$dyn_table.= '<tr><table>' ;
?>
我的HTML
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<?php echo $dyn_table;?>
</body>
</html>
我的问题 结果是OK,但有重复。如何获得独特的结果?
你应该检查[array_unique](http://php.net/manual/en/function.array-unique.php) –
选择不同的返回只有不重复所以...更新你的问题与数据采样。,你的实际结果和预期结果 – scaisEdge
你期望的结果是什么? – Shibon