以后上午就只能这样了么-jQuery,上午么-jquery
以后上午就只能这样了么-jQuery,上午么-jquery
hi
昨天睡得不错
为什么早上还是看不进论文,宁愿做这个,也不愿认真看论文。感觉上还是下午看论文感觉要好的多。不过最近有三十多篇要看哇。。。管球。。。
1、jQuery
-----jQuery常用插件-----
----表单插件——form
通过表单form插件,调用ajaxForm()
方法,实现ajax方式向服务器提交表单数据,并通过方法中的options对象获取服务器返回数据,调用格式如下:
<strong>$(form). ajaxForm ({options})</strong>
其中form参数表示表单元素名称;options是一个配置对象,用于在发送ajax请求过程,设置发送时的数据和参数。
----图片灯箱插件——lightBox
该插件可以用圆角的方式展示选择中的图片,使用按钮查看上下张图片,在加载图片时自带进度条,还能以自动播放的方式浏览图片,调用格式如下:
<strong>$(linkimage).lightBox({options})</strong>
其中linkimage参数为包含图片的元素名称,options为插件方法的配置对象。
我的相册
----图片放大镜插件——jqzoom
在调用jqzoom图片放大镜插件时,需要准备一大一小两张一样的图片,在页面中显示小图片,当鼠标在小图片中移动时,调用该插件的jqzoom()
方法,显示与小图片相同的大图片区域,从而实现放大镜的效果,调用格式如下:
<strong>$(linkimage).jqzoom({options})</strong>
其中linkimage参数为包含图片的元素名称,options为插件方法的配置对象。
----cookie插件——cookie
使用cookie插件后,可以很方便地通过cookie对象保存、读取、删除用户的信息,还能通过cookie插件保存用户的浏览记录,它的调用格式为:
保存:<strong>$.cookie(key</strong><strong>,</strong><strong>value)</strong>
;读取:<strong>$.cookie(key)</strong>
,删除:<strong>$.cookie(key</strong><strong>,</strong><strong>null)</strong>
其中参数key为保存cookie对象的名称,value为名称对应的cookie值。
cookie插件
邮箱:
是否保存邮箱
----搜索插件——autocomplete
搜索插件的功能是通过插件的autocomplete()
方法与文本框相绑定,当文本框输入字符时,绑定后的插件将返回与字符相近的字符串提示选择,调用格式如下:
<strong>$(textbox).autocomplete(urlData,[options]);</strong>
其中,textbox参数为文本框元素名称,urlData为插件返回的相近字符串数据,可选项参数options为调用插件方法时的配置对象。
搜索插件
用户名
----右键菜单插件——contextmenu
右键菜单插件可以绑定页面中的任意元素,绑定后,选中元素,点击右键,便通过该插件弹出一个快捷菜单,点击菜单各项名称执行相应操作,调用代码如下:
<strong>$(selector).contextMenu(menuId,{options});</strong>
Selector参数为绑定插件的元素,meunId为快捷菜单元素,options为配置对象。
-
保存
-
退出
----自定义对象级插件——lifocuscolor插件
自定义的lifocuscolor插件可以在
- 元素中,鼠标在表项
- 元素移动时,自定义其获取焦点时的背景色,即定义
- 元素选中时的背景色,调用格式为:
<strong>$(Id).focusColor(color)</strong>
其中,参数Id表示
- 元素的Id号,color表示
- 元素选中时的背景色。
对象级别的插件
- 橘子水果
- 芹菜蔬菜
- 香蕉水果
----自定义类级别插件—— twoaddresult
通过调用自定义插件twoaddresult中的不同方法,可以实现对两个数值进行相加和相减的运算,导入插件后,调用格式分别为:
<strong>$.addNum(p1,p2) </strong>
和<strong> $.subNum(p1,p2)</strong>
上述调用格式分别为计算两数值相加和相减的结果,p1和p2为任意数值。
自定义类级别插件
两数相减:
-
=
2、MySQL&PHP
-----php内置MySQL函数(一)-----
----连接数据库
mysql_connect
mysql_connect('localhost','root','');
也就是说这个函数有3个参数,数据库名或者ip地址,用户名,密码
注意,一般认为mysql_connect在以后的版本不再支持(php5.5以后版本似乎)改用mysqi_connect就可以了
if(mysqli_connect('localhost','root','')){
echo "连接成功";}else{
echo "shit";
}测试代码如上
连接成功后,会返回mysql连接标识符(用处下面会提到);失败的话会返回false
---数据库扩展
PHP中一个数据库可能有一个或者多个扩展,其中既有官方的,也有第三方提供的。像Mysql常用的扩展有原生的mysql库,也可以使用增强版的mysqli扩展,还可以使用PDO进行连接与操作。
不同的扩展提供基本相近的操作方法,不同的是可能具备一些新特性,以及操作性能可能会有所不同。
mysql扩展进行数据库连接的方法:
$link = mysql_connect('mysql_host', 'mysql_user', 'mysql_password');
Copy after loginmysqli扩展:
$link = mysqli_connect('mysql_host', 'mysql_user', 'mysql_password');
Copy after loginPDO扩展
$dsn = 'mysql:dbname=testdb;host=127.0.0.1'; $user = 'dbuser'; $password = 'dbpass'; $dbh = new PDO($dsn, $user, $password);
Copy after login----关闭数据库连接
mysql_close
mysql_close($con);关闭上一条的连接,这里的$con是mysql_connect()成功后返回的标识符
$con=mysqli_connect('localhost','root','','info');
----选择数据库
mysql_select_db()
$con=mysqli_connect('localhost','root','','info');
if($con){
echo "连接成功";
}else{
echo "shit";
}
//mysql_close($con);
if(mysqli_select_db($con, 'info')){
echo "成功";
}else{
echo "shit";
}由于我的php版本较高,mysql基本不认,所以我都改用mysqli,不过基本用法都差不多,就是参数要注意一下。一般来说,编译软件(我用Zend)都是有提示的,不用担心
----执行SQL语句
mysqli_query()
mysqli_query($con, "INSERT test(name) VALUES('Tom')");
mysqli是要求连接的,$con
---执行MySQL查询
在数据库建立连接以后就可以进行查询,采用mysql_query加sql语句的形式向数据库发送查询指令。
$res = mysql_query('select * from user limit 1');
Copy after login对于查询类的语句会返回一个资源句柄(resource),可以通过该资源获取查询结果集中的数据。
$row = mysql_fetch_array($res); var_dump($row);
Copy after login默认的,PHP使用最近的数据库连接执行查询,但如果存在多个连接的情况,则可以通过参数指令从那个连接中进行查询。
$link1 = mysql_connect('127.0.0.1', 'code1', ''); $link2 = mysql_connect('127.0.0.1', 'code1', '', true); //开启一个新的连接 $res = mysql_query('select * from user limit 1', $link1); //从第一个连接中查询数据
Copy after login//连接数据库
mysql_connect('127.0.0.1', 'code1', '');
mysql_select_db('code1');
mysql_query("set names 'utf8'");
//在这里进行数据查询
$res = mysql_query("select * from user limit 1");$row = mysql_fetch_array($res);
var_dump($row);
---插入新数据到MySQL中
当我们了解了如何使用mysql_query进行数据查询以后,那么类似的,插入数据其实也是通过执行一个sql语句来实现,例如:
$sql = "insert into user(name, age, class) values('李四', 18, '高三一班')"; mysql_query($sql); //执行插入语句
Copy after login通常数据都是存储在变量或者数组中,因此sql语句需要先进行字符串拼接得到。
$name = '李四'; $age = 18; $class = '高三一班'; $sql = "insert into user(name, age, class) values('$name', '$age', '$class')"; mysql_query($sql); //执行插入语句
Copy after login在mysql中,执行插入语句以后,可以得到自增的主键id,通过PHP的mysql_insert_id函数可以获取该id。
$uid = mysql_insert_id();
Copy after login这个id的作用非常大,通常可以用来判断是否插入成功,或者作为关联ID进行其他的数据操作。
//连接数据库
mysql_connect('127.0.0.1', 'code1', '');
mysql_select_db('code1');
mysql_query("set names 'utf8'");
//已知的数据变量有
$name = '李四';
$age = 18;
$class = '高三一班';
//在这里进行数据查询
$sql="insert into user(name,age,class) value ('$name','$age','$class')";
mysql_query($sql);
$uid=mysql_insert_id();
print_r($uid);要回去看中国队的比赛了,明天继续
- 元素选中时的背景色。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











Detailed explanation of jQuery reference method: Quick start guide jQuery is a popular JavaScript library that is widely used in website development. It simplifies JavaScript programming and provides developers with rich functions and features. This article will introduce jQuery's reference method in detail and provide specific code examples to help readers get started quickly. Introducing jQuery First, we need to introduce the jQuery library into the HTML file. It can be introduced through a CDN link or downloaded

How to use PUT request method in jQuery? In jQuery, the method of sending a PUT request is similar to sending other types of requests, but you need to pay attention to some details and parameter settings. PUT requests are typically used to update resources, such as updating data in a database or updating files on the server. The following is a specific code example using the PUT request method in jQuery. First, make sure you include the jQuery library file, then you can send a PUT request via: $.ajax({u

jQuery is a fast, small, feature-rich JavaScript library widely used in front-end development. Since its release in 2006, jQuery has become one of the tools of choice for many developers, but in practical applications, it also has some advantages and disadvantages. This article will deeply analyze the advantages and disadvantages of jQuery and illustrate it with specific code examples. Advantages: 1. Concise syntax jQuery's syntax design is concise and clear, which can greatly improve the readability and writing efficiency of the code. for example,

Title: jQuery Tips: Quickly modify the text of all a tags on the page In web development, we often need to modify and operate elements on the page. When using jQuery, sometimes you need to modify the text content of all a tags in the page at once, which can save time and energy. The following will introduce how to use jQuery to quickly modify the text of all a tags on the page, and give specific code examples. First, we need to introduce the jQuery library file and ensure that the following code is introduced into the page: <

Title: Use jQuery to modify the text content of all a tags. jQuery is a popular JavaScript library that is widely used to handle DOM operations. In web development, we often encounter the need to modify the text content of the link tag (a tag) on the page. This article will explain how to use jQuery to achieve this goal, and provide specific code examples. First, we need to introduce the jQuery library into the page. Add the following code in the HTML file:

How to remove the height attribute of an element with jQuery? In front-end development, we often encounter the need to manipulate the height attributes of elements. Sometimes, we may need to dynamically change the height of an element, and sometimes we need to remove the height attribute of an element. This article will introduce how to use jQuery to remove the height attribute of an element and provide specific code examples. Before using jQuery to operate the height attribute, we first need to understand the height attribute in CSS. The height attribute is used to set the height of an element

jQuery is a popular JavaScript library that is widely used to handle DOM manipulation and event handling in web pages. In jQuery, the eq() method is used to select elements at a specified index position. The specific usage and application scenarios are as follows. In jQuery, the eq() method selects the element at a specified index position. Index positions start counting from 0, i.e. the index of the first element is 0, the index of the second element is 1, and so on. The syntax of the eq() method is as follows: $("s

How to tell if a jQuery element has a specific attribute? When using jQuery to operate DOM elements, you often encounter situations where you need to determine whether an element has a specific attribute. In this case, we can easily implement this function with the help of the methods provided by jQuery. The following will introduce two commonly used methods to determine whether a jQuery element has specific attributes, and attach specific code examples. Method 1: Use the attr() method and typeof operator // to determine whether the element has a specific attribute
