Programming... & Nbsp; the existing MYSQL database server with the username root and password root has a database named mongogl, how to use PHP programming to display the first 15 records of the student table in the PostgreSQL GL database, and use mysql_connect ('localh for programming...
The existing MYSQL database server with the username "root" and password "root" has a database named mongogl. how to use PHP programming to display the first 15 records of the student table in the mongogl database
------ Solution --------------------
Mysql_connect ('localhost', 'root', 'root') or die (mysql_error ());
Mysql_select_db ('invalid GL ') or die (mysql_error ());
$ Rs = mysql_query ('select * from student limit 15') 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 ('invalid GL ') or die (mysql_error ());
// Assume that your field name is 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 ).'
';
}
------ 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