Programming. Solution Solutions

Source: Internet
Author: User
Programming ...
The existing user name is root, the password is root MySQL database server, which has a database named JWGL, how to use PHP programming to display the JWGL Database student table of the first 15 records
------Solution--------------------
mysql_connect (' localhost ', ' root ', ' root ') or Die (Mysql_error ());
mysql_select_db (' Jwgl ') or Die (Mysql_error ());
$rs = mysql_query (' SELECT * from student limit ") or Die (Mysql_error ());
while ($r = Mysql_fetch_assoc ($rs)) {
echo Join (", $r). '
';
}


------Solution--------------------


mysql_connect (' localhost ', ' root ', ' root ') or Die (Mysql_error ());
mysql_select_db (' Jwgl ') or Die (Mysql_error ());

$rs = mysql_query (' SELECT * FROM student ORDER BY id desc-limit ') or Die (Mysql_error ());
while ($r = Mysql_fetch_assoc ($rs)) {
echo Join (", $r). '
';
}


------Solution--------------------

$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]."
";//or $row [" Test_col "]
}
Mysql_close ($conn);

------Solution--------------------
SELECT * FROM student limit 0,15
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.