Php practice 16th days

Source: Internet
Author: User
The following figure shows the front-end and back-end. the front-end uses the template last Friday. the background is hand-written. today, I learned that css overflow settings are out of range. I can give the scroll bar or hide the scroll bar overflow: hidden is another mysql class for hiding php. super... "/> <scripttype =" text/javascript "src

The following figure shows the front-end and back-end. the front-end uses the template of last Friday. the back-end is hand-written.

 

Today I learned

When the css overflow settings are out of the range, you can give the scroll bar or hide the scroll bar.

Overflow: hidden is hidden.

I wrote another mysql class in php, which is super simple.


[Php]
/**
* Mysql operation class
*/
Class db_mysql
{
Var $ conn;
 
Function _ construct ($ localhost, $ userName, $ password, $ dbName)
{
$ This-> conn = mysql_connect ($ localhost, $ userName, $ password );
 
Mysql_select_db ($ dbName, $ this-> conn );
Mysql_query ("set names utf8", $ this-> conn );
 
}
 
Function _ destruct ()
{
Mysql_close ($ this-> conn );
}
 
 
Function query ($ SQL)
{
// Echo $ SQL;
Return mysql_query ($ SQL, $ this-> conn );
 
}
 
 
}
?>

/**
* Mysql operation class
*/
Class db_mysql
{
Var $ conn;

Function _ construct ($ localhost, $ userName, $ password, $ dbName)
{
$ This-> conn = mysql_connect ($ localhost, $ userName, $ password );

Mysql_select_db ($ dbName, $ this-> conn );
Mysql_query ("set names utf8", $ this-> conn );

}

Function _ destruct ()
{
Mysql_close ($ this-> conn );
}


Function query ($ SQL)
{
// Echo $ SQL;
Return mysql_query ($ SQL, $ this-> conn );

}


}
?>

Today I encountered a tangle of problems, interactive actions... I wanted to write a single entry form of mvc, but the speed of code writing would not be slow, and then I took a solution that seems good all the time.

1. create the action folder and type. php for article column operations.

2. create article. php for document operations,

In this case, I only need to "/action/type. php? Action = list "get it done. then execute the corresponding code to determine what to execute. the switch statement is used.


[Php]
? Php
Require '../inc. php ';
 
Switch ($ _ GET ['action']) {
 
Case 'submit ':
If (! Empty ($ _ POST ['typename']) {

$ Json ['state'] = "no ";
 
$ Bool = $ db-> query ("insert into typename ('name') value ('{$ _ POST ['typename']}')");
If ($ bool ){
$ Json ['state'] = "OK ";
} Else {
$ Json ['error'] = 'column insertion failed ';
}
Echo json_encode ($ json );
}
 
Break;
Case 'List ':
$ Result = $ db-> query ('select * from typename ');
$ Arr = array ();
While ($ row = mysql_fetch_assoc ($ result )){
$ Arr [] = $ row;
}
Echo json_encode ($ arr );
Break;
 
Default:
# Code...
Break;
}
 
 
?>

Require '../inc. php ';

Switch ($ _ GET ['action']) {

Case 'submit ':
If (! Empty ($ _ POST ['typename']) {

$ Json ['state'] = "no ";

$ Bool = $ db-> query ("insert into typename ('name') value ('{$ _ POST ['typename']}')");
If ($ bool ){
$ Json ['state'] = "OK ";
} Else {
$ Json ['error'] = 'column insertion failed ';
}
Echo json_encode ($ json );
}

Break;
Case 'List ':
$ Result = $ db-> query ('select * from typename ');
$ Arr = array ();
While ($ row = mysql_fetch_assoc ($ result )){
$ Arr [] = $ row;
}
Echo json_encode ($ arr );
Break;

Default:
# Code...
Break;
}


?>

 

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.