日期:2014-05-17 浏览次数:20511 次
mysql_connect('localhost', 'root', 'root') or die(mysql_error());
mysql_select_db('JWGL') or die(mysql_error());
//假设你的编号字段名为 id
$rs = mysql_query('select * from student order by id desc limit 15') or die(mysql_error());
while($r = mysql_fetch_assoc($rs)) {
echo join(' ', $r) . '<br />';
}
$mysql_server_name='localhost';
$mysql_username='root';
$mysql_password='root';
$mysql_database='JWGL';
$mysql_table='student';
$conn=mysql_connect($mysql_server_name,$mysql_username,$mysql_password,$mysql_database) or die(mysql_error());
mysql_select_db($mysql_database,$conn);
$sql='SET NAMES UTF8';//if utf8
mysql_query($sql);
$queStr ='SELECT * FROM '.$mysql_table.' ORDER BY id ASC LIMIT 0,15';//if pri key id
$result=mysql_query($queStr);
while($row = mysql_fetch_array($result)){
echo $row[0]." ".$row[1]."<br />";//or $row["test_col"]
}
mysql_close($conn);