Help ~ It may be a small problem. PHPcode $ query & quot; SELECT * fromnewsORDERbyiddescLimit $ offset, $ page_size & quot; $ resultmysql_query ($ query, $ conn); $ rowmysql_fetch_array ($ result ); $ i0; whil help ~ It may be a small problem
PHP code
$query="SELECT * from news ORDER by id desc Limit $offset,$page_size";$result=mysql_query($query,$conn);$row=mysql_fetch_array($result);$i=0;while($i<$rows=mysql_num_rows($result)){ $i++; echo ""; echo "
"; echo "
"; echo "
| "; echo "".$row["title"].""; echo " | "; echo "
"; echo "[".$row["author"]."]"; echo " | "; echo "
"; echo "[".$row["date"]."]"; echo " | "; echo "
"; } echo "
";
The result is as follows:
Test4 [aa] [15:36:00]
Test4 [aa] [15:36:00]
Test4 [aa] [15:36:00]
Test4 [aa] [15:36:00]
The number of repetitions is the number of data records stored in my database. how can I display the data from the first entry?
For example:
Test1 [aa] [15:36:00]
Test2 [aa] [15:36:00]
Test3 [aa] [15:36:00]
Test4 [aa] [15:36:00]
Thank you again ~ ^
------ Solution --------------------
Correct row.
While ($ row = mysql_fetch_array ($ result )){
Discussion
// $ Row = mysql_fetch_array ($ result); // deleted
While ($ rows = mysql_fetch_array ($ result )){
------ Solution --------------------
Your $ row has never changed. it must be the same data.
------ Solution --------------------
$ Query = "SELECT * from news ORDER by id desc Limit $ offset, $ page_size ";
$ Result = mysql_query ($ query, $ conn );
// $ Row = mysql_fetch_array ($ result); this row is placed in the while condition.
No need for this $ I
// While ($ I <$ rows = mysql_num_rows ($ result )){
// $ I ++;
While ($ row = mysql_fetch_array ($ result )){
Echo"
";
Echo"
";Echo"
";Echo"
";
Echo "". $ row ["title"]. "";
Echo" | ";Echo"
";
Echo "[". $ row ["author"]. "]";
Echo" | ";Echo"
";
Echo "[". $ row ["date"]. "]";
Echo" | ";Echo"
";}Echo"
";