Is this the only thing that can happen in the morning?-jquery, Morning-jquery_php tutorial

Source: Internet
Author: User
Tags dsn

Is this the only thing that can happen in the morning?-jquery, Morning-jquery


Hi

Slept well yesterday.

Why do not read the paper in the morning, would rather do this, do not want to seriously read the paper. It feels better to read the paper in the afternoon. But recently more than 30 to see Wow ... Tube Ball ...

1. JQuery

-----jquery Common Plug-ins-----

----Form plug-in--form

Through form form plug-in, call ajaxForm() method, implement Ajax way to submit form data to the server, and through the options object in the method to get the server return data, the call format is as follows:

$(form). ajaxForm ({options})

Where the form parameter represents the form element name; Options is a configuration object that is used to send the AJAX request process to set the data and parameters to be sent.





----Picture Lightbox plugin--lightbox

The plugin can be rounded to show the selection of pictures, use the button to view the top and bottom picture, when loading the picture with a progress bar, but also to automatically play the way to browse the picture, the call format is as follows:

$(linkimage).lightBox({options})

Where the linkimage parameter is the element name that contains the picture, options is the configuration object for the plug-in method.




My albums



















----Picture Magnifier plugin--jqzoom

In the call Jqzoom Picture Magnifier plug-in, you need to prepare a small two of the same picture, display small pictures in the page, when the mouse in the small picture in the move, call the plug-in jqzoom() method, display the same large picture area with the small picture, so as to achieve the effect of the magnifying glass, the call format is as follows:

$(linkimage).jqzoom({options})

Where the linkimage parameter is the element name that contains the picture, options is the configuration object for the plug-in method.




Picture Magnifier









----Cookie Plugin--cookie

After using the cookie plugin, it is convenient to save, read, delete the user's information through the cookie object, and to save the user's browsing record through the cookie plugin, which is called in the following format:

Save: $.cookie(keyvalue) ; read: $.cookie(key) , Delete:$.cookie(keynull)

Where parameter key is the name of the saved cookie object, value is the cookie value corresponding to the name.




Cookie Plugin





Email:



Whether to save the mailbox




----Search Plugin--autocomplete

The function of the search plugin is bound by the method of plug-in autocomplete() and the text box, when the text box enters the character, the bound plug-in will return the string prompt selection similar to the character, the calling format is as follows:

$(textbox).autocomplete(urlData,[options]);

Where the textbox parameter is the text box element name, Urldata is the similar string data returned by the plug-in, the optional parameter options are the configuration object when the plug-in method is called.




Search Plugin


User name








----Right-click menu plugin--contextmenu

The right-click menu plug-in can be bound to any element of the page, after binding, select the element, right-click, then through the plug-in popup A shortcut menu, click the menu name to do the corresponding action, the calling code is as follows:

$(selector).contextMenu(menuId,{options});

The selector parameter is the element that binds the plug-in, Meunid is the shortcut menu element, and options is the configuration object.



Click the right button






    • Save

    • Exit






----Custom Object-level plug-in--lifocuscolor plug-in

The custom Lifocuscolor plugin can be

    element, the mouse in the table item
  • When the element is moved, customize its background color when it gets focus, defined
  • The background color when the element is selected, called in the format:

    $(Id).focusColor(color)

    Where the parameter ID represents

      The ID number of the element, color indicates
    • The background color when the element is selected.




      Object-level plug- in



        • Orange Fruit

        • Celery Vegetable

        • Banana Fruit






      ----Custom class-level plug-ins--twoaddresult

      By invoking the different methods in the custom plug-in Twoaddresult, you can add and subtract two values, and after importing the plug-in, the calling format is:

      $.addNum(p1,p2) And $.subNum(p1,p2)

      The call format is calculated as the result of adding and subtracting two values, p1 and P2 are arbitrary values.




      custom class-level plug-ins





      Subtract two numbers:

      -

      =





      2, mysql&php

      -----PHP built-in MySQL function (a)-----

      ----Connect to a database

      Mysql_connect

      mysql_connect (' localhost ', ' root ', ');

      That is, this function has 3 parameters, database name or IP address , user name, password

      Note that mysql_connect is generally considered to be no longer supported in later versions (php5.5 later versions seem to be) instead of mysqi_connect.

      if (Mysqli_connect (' localhost ', ' root ', ')) {
      echo "Connected successfully";

      }else{
      echo "Shit";
      }

      Test code above

      After the connection is successful, the MySQL connection identifier is returned (the usefulness is mentioned below), and if it fails, it returns false.

      --- database extensions

      A database in PHP may have one or more extensions, both official and third-party. The usual extensions like MySQL have native MySQL libraries, you can also use the enhanced version of the mysqli extension, and you can use PDO for connection and operation.

      Different extensions provide a basic approach to operations, but the difference is that there may be some new features, and operational performance may vary.

      MySQL extension how to connect to a database:

      $link = mysql_connect (' mysql_host ', ' mysql_user ', ' Mysql_password ');

      MYSQLI Extensions:

      $link = Mysqli_connect (' mysql_host ', ' mysql_user ', ' Mysql_password ');

      PDO extension

      $dsn = ' mysql:dbname=testdb;host=127.0.0.1 '; $user = ' dbuser '; $password = ' Dbpass '; $dbh = new PDO ($DSN, $user, $password);

      ----Close the database connection

      Mysql_close

      Mysql_close ($con); Closes the previous connection, where $con is the identifier returned after the mysql_connect () succeeds

      $con =mysqli_connect (' localhost ', ' root ', ' ', ' info ');

      ----Select a database

      mysql_select_db ()

      $con =mysqli_connect (' localhost ', ' root ', ' ', ' info ');
      if ($con) {
      echo "Connected successfully";
      }else{
      echo "Shit";
      }
      Mysql_close ($con);
      if (mysqli_select_db ($con, ' info ')) {
      echo "Success";
      }else{
      echo "Shit";
      }

      Because my PHP version is high, MySQL basically do not recognize, so I have to use mysqli, but the basic usage is similar, is the parameter to pay attention to. Generally speaking, compiling software (I use Zend) is a hint, do not worry

      ----Execute SQL statements

      Mysqli_query ()

      Mysqli_query ($con, "INSERT test (name) VALUES (' Tom ')");

      The mysqli is required to be connected, $con

      ---execute MySQL Query

      After the database is established, queries can be made, and query instructions are sent to the database in the form of mysql_query plus SQL statements.

      $res = mysql_query (' select * from user Limit 1 ');

      The statement for the query class returns a resource handle (resource) from which the data in the query result set can be obtained.

      $row = Mysql_fetch_array ($res); Var_dump ($row);

      By default, PHP executes the query using the most recent database connection, but if there are multiple connections, you can query from that connection by parameter directives.

      $link 1 = mysql_connect (' 127.0.0.1 ', ' code1 ', '); $link 2 = mysql_connect (' 127.0.0.1 ', ' code1 ', ', true); Open a new connection $res = mysql_query (' select * from user Limit 1 ', $link 1); Querying data from the first connection

      Connecting to a database
      mysql_connect (' 127.0.0.1 ', ' code1 ', ');
      mysql_select_db (' Code1 ');
      mysql_query ("Set names ' UTF8 '");
      Do a data query here
      $res = mysql_query ("SELECT * from User limit 1");

      $row = Mysql_fetch_array ($res);

      Var_dump ($row);

      ---inserting new data into MySQL

      When we understand how to use mysql_query for data queries, then, similarly, inserting data is actually done by executing an SQL statement, for example:

      $sql = "INSERT into user (name, age, Class) VALUES (' John Doe ', 18, ' 31 classes ')"; mysql_query ($sql); Execute INSERT statement

      Usually data is stored in variables or arrays, so SQL statements need to be preceded by string concatenation.

      $name = ' John doe '; $age = +; $class = ' high 31 classes '; $sql = "INSERT into user (name, age, Class) VALUES (' $name ', ' $age ', ' $class ')"; MySQL _query ($sql); Execute INSERT statement

      In MySQL, after executing the INSERT statement, you can get the self-increment primary key ID, which can be obtained through PHP's mysql_insert_id function.

      $uid = mysql_insert_id ();

      This ID is very useful, and can often be used to determine whether the insert succeeds or to perform other data operations as an association ID.

      Connecting to a database
      mysql_connect (' 127.0.0.1 ', ' code1 ', ');
      mysql_select_db (' Code1 ');
      mysql_query ("Set names ' UTF8 '");
      The known data variables have
      $name = ' John Doe ';
      $age = 18;
      $class = ' High 31 classes ';
      Do a data query here
      $sql = "INSERT into user (Name,age,class) value (' $name ', ' $age ', ' $class ')";
      mysql_query ($sql);
      $uid =mysql_insert_id ();
      Print_r ($UID);

      To go back to the Chinese team and continue tomorrow.

      http://www.bkjia.com/PHPjc/1072327.html www.bkjia.com true http://www.bkjia.com/PHPjc/1072327.html techarticle the morning will be the only way to do that?-jquery, morning-jquery Hi slept well why in the morning or not to see the paper, would rather do this, do not want to seriously read the paper. Feel the next ...

Related Article

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.