$query?=?"select?*?from?userlist?where?username?=?'$lune'?ORDER?BY?id?DESC?LIMIT?1";?
創(chuàng)新互聯(lián)作為成都網(wǎng)站建設(shè)公司,專注重慶網(wǎng)站建設(shè)、網(wǎng)站設(shè)計(jì),有關(guān)成都企業(yè)網(wǎng)站定制方案、改版、費(fèi)用等問題,行業(yè)涉及成都餐廳設(shè)計(jì)等多個(gè)領(lǐng)域,已為上千家企業(yè)服務(wù),得到了客戶的尊重與認(rèn)可。
$result?=?mysqli_query($link,?$query);?
$row?=?mysqli_fetch_array($result);?
echo?$row['gangwei'];
最簡單的方式,既然有ID,直接通過ID排序,取一條即可.
您使用了limit 0,1就只有一條了,就是你要的最后一條。也許你問的問題沒有說清楚
select a.name name1,a.*,b.value,b.* from piwik_site a,piwik_archive_numeric_2013_10 b where b.period in(1,2,3) and b.name='nb_visits' and a.idsite=b.idsite order by b.value desc
如果頁面顯示的是這個(gè)語句,那么最后一個(gè)應(yīng)該是select a.name name1,a.*,b.value,b.* from piwik_site
a,piwik_archive_numeric_2013_10 b where b.period in(1,2,3) and
b.name='nb_visits' and a.idsite=b.idsite order by b.value asc limit 1
或者先執(zhí)行一次select count(*) 拿到數(shù)量num,再select a.name name1,a.*,b.value,b.* from piwik_site
a,piwik_archive_numeric_2013_10 b where b.period in(1,2,3) and
b.name='nb_visits' and a.idsite=b.idsite order by b.value desc limit num-1,1
$con = mysql_connect("localhost","root","");//連接數(shù)據(jù)庫
mysql_select_db("btxiazai",$con);//選擇數(shù)據(jù)庫
mysql_query("set names utf8");
$sql = "select * from persons order by id desc limit 2";//獲取persons中的數(shù)據(jù),并按id倒敘排列,取其中兩條
$get = mysql_query($sql);//執(zhí)行sql
while($result = mysql_fetch_assoc($get)){//取回?cái)?shù)據(jù)
}
名稱欄目:php獲取最后一組數(shù)據(jù) php 取數(shù)組第一個(gè)
鏈接URL:http://muchs.cn/article26/hgscjg.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供自適應(yīng)網(wǎng)站、App開發(fā)、網(wǎng)站維護(hù)、外貿(mào)建站、虛擬主機(jī)、面包屑導(dǎo)航
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)