$sql = "SELECT * from a where id= ' $Id '"; $result = $mysqli->query ($sql), while ($r = $result->fetch_assoc ()) {echo $r. '
';//Cycle 5 times. }
The result is
1: Name 2
2: Name 1
3: Name 1
4: Name 3
5: Name 1
If only 1 times the name 1 in the loop, how is it written?
Reply to discussion (solution)
Don't know how your data is organized!
An ID actually corresponds to 5 records
Besides $r = $result->fetch_assoc () is the array
You echo $r. '
'; It's impossible to get what you're saying.
$sql = "SELECT * from a where id= ' $Id '"; $result = $mysqli->query ($sql), while ($r = $result->fetch_assoc ()) $r =array_ Unique ($r);p Rint_r ($r)
Don't know how your data is organized!
An ID actually corresponds to 5 records
Besides $r = $result->fetch_assoc () is the array
You echo $r. '
'; It's impossible to get what you're saying.
The structure of the data is that
A table name B table Article
According to the article B of the latest and newest, call a table name, said who updated the article.
If 1 people have updated the N article continuously, it repeats.
$sql = "SELECT * from a where id= ' $Id '"; $result = $mysqli->query ($sql), while ($r = $result->fetch_assoc ()) $r =array_ Unique ($r);p Rint_r ($r)
This is also a way, but I am this is 2 tables at the same time query. This is a good idea if you use a view.
Query Plus DISTINCT Property
Suggest that you put out your
Create Table ....;
Insert into Table .... Statement
What are the expected results, and simply describe the algorithm logic.
Suggest that you put out your
Create Table ....;
Insert into Table .... Statement
What are the expected results, and simply describe the algorithm logic.
Complete the following. Trouble to see.
$c = "Select A.id,a.name,a.dcname,a.curl,a.item1,b.nid, b.xclass,b.title,b.nurl,b.createdate from XClass a,news b where A.name=b.xclass ORDER by Nid desc limit 0,15 "; $result = $mysqli->query ($c), while ($rsrow = $result->fetch_assoc ()) { $xsURL = "; if ($rsrow [' CURL ']== ') {$xsURL = $rsrow [' id '];} else{$xsURL = $rsrow [' CURL '];} $zjURL = "; if ($rsrow [' Nurl ']== ') {$zjURL = $rsrow [' Nid '];} else{$zjURL = $rsrow [' Nurl '];} $chadaleiName = $rsrow [' dcname ']; $chadalei = "SELECT * from Dclass where name= ' $chadaleiName '"; $cha = $mysqli->query ($chadalei); $chaRs = $cha->fetch_assoc (); $LEIBIEURL = "; if ($chaRs [' CName ']== ') {$leibieUrl = $chaRs [' Id '];} else{$leibieUrl = $chaRs [' CName '];} $cha->free (); $shijian = $rsrow [' CreateDate ']; $zj. = '
['. $chaRs [' Name ']. ']'; $zj. = '. $rsrow [' Xclass ']. '; $zj. = '. $rsrow [' Title ']; $zj. = '. $rsrow [' Item1 ']. ' '. Date (' H:i:s ', Strtotime ($shijian)). ''; $zj. = $xsURL. '--'. $rsrow [' Xclass ']. ' -'. $zjURL. '-' $rsrow [' Title ']. ' --
';}