国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

Home php教程 PHP源碼 結(jié)合AJAX進(jìn)行PHP開發(fā)之入門(二)

結(jié)合AJAX進(jìn)行PHP開發(fā)之入門(二)

Jun 08, 2016 pm 05:33 PM
limit link output start step

<script>ec(2);</script>

導(dǎo)航的實(shí)現(xiàn)

  雖然表格列出了目錄中的一些圖像,但用戶還需要一種查看表格中未出現(xiàn)的圖片的方法。要真正實(shí)現(xiàn)分頁器的導(dǎo)行,則需要一套標(biāo)準(zhǔn)的鏈接:首頁、上一頁、下一頁和尾頁。

  清單 3. 分頁器導(dǎo)航

// Append navigation
$output = '

Showing items ' . $limit_start . '-' .
min($limit_start $limit_step - 1, count($images)) .
' of ' . count($images) . '
';

$prev_start = max(0, $limit_start - $limit_step);
if ( $limit_start > 0 ) {
 $output .= get_table_link('  $output .= ' | ' . get_table_link('Prev',
 $prev_start, $limit_step);
} else {
 $output .= ' }

// Append next button
$next_start = min($limit_start $limit_step, count($images));
if ( $limit_start $limit_step  $output .= ' | ' . get_table_link('Next',$next_start, $limit_step);
 $output .= ' | ' . get_table_link('>>',(count($images) - $limit_step), $limit_step);
} else {
 $output .= ' | Next | >>';
}

$output .= '

';

  最后還要編寫 get_image_link() 和 get_table_link() 函數(shù),讓用戶將縮略圖展開成完整的圖像(參見清單 4)。注重,腳本 index.php(以及后面要?jiǎng)?chuàng)建的 expand.php)只在這兩個(gè)函數(shù)中調(diào)用。這樣就很輕易改變鏈接的功能。事實(shí)上在下面與 Sajax 進(jìn)行集成時(shí),只有這兩個(gè)函數(shù)需要修改。

  清單 4. get_image_link、get_table_link 實(shí)現(xiàn)

function get_table_link ( $title, $start, $step ) {
 $link = "index.php?start=$start&step=$step";
 return '' . $title .'';
}

function get_image_link ( $title, $index ) {
 $link = "expand.php?index=$index";
 return '' . $title . '';
}

  放大圖片

  現(xiàn)在有了一個(gè)可用的分頁器為用戶提供一些縮略圖。相冊(cè)的第二項(xiàng)功能是答應(yīng)用戶單擊縮略圖來查看全圖。get_image_link() 函數(shù)調(diào)用了 expand.php 腳本,我們現(xiàn)在就來編寫它。該腳本傳遞用戶希望展開的文件的索引,因此必須在此列出目錄并獲得適當(dāng)?shù)奈募?。隨后的操作就很簡單了,只需創(chuàng)建病輸出 image 標(biāo)記即可。

  清單 5. get_image 函數(shù)

function get_image ( $index ) {
 $images = get_image_list ( 'images' );

 // Generate navigation

 $output .= '結(jié)合AJAX進(jìn)行PHP開發(fā)之入門(二)';
 return $output;
}
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Detailed explanation of how to use take and limit in Laravel Detailed explanation of how to use take and limit in Laravel Mar 10, 2024 pm 05:51 PM

"Detailed explanation of how to use take and limit in Laravel" In Laravel, take and limit are two commonly used methods, used to limit the number of records returned in database queries. Although their functions are similar, there are some subtle differences in specific usage scenarios. This article will analyze the usage of these two methods in detail and provide specific code examples. 1. Take method In Laravel, the take method is used to limit the number of records returned, usually combined with the orderBy method.

What should I do if docker start cannot start? What should I do if docker start cannot start? Oct 21, 2022 pm 03:43 PM

Solution to docker start failure: 1. Check the running status, and then release the occupied memory through the "echo 3 &gt; /proc/sys/vm/drop_caches" command; 2. Use "$netstat -nltp|grep .. ." command to check whether the port has been occupied. If it is found to be occupied after going online, change it to an available port and restart.

What file is step? What file is step? Dec 20, 2023 pm 05:22 PM

The STEP file format is an important 3D model data exchange format. It plays an important role in CAD, CAM and other related fields. Its standardization and widespread application help improve work efficiency, reduce the complexity of data conversion, and Promote interoperability between different systems. The full name is "Standard Terminal Equipment Protocol", which is three-dimensional image data based on the text-encoded exchange structure of the ASCII format that complies with the STEP application protocol ISO 10303-21 standard.

A deep dive into the differences between take and limit in Laravel A deep dive into the differences between take and limit in Laravel Mar 10, 2024 pm 01:00 PM

In Laravel, we often use some methods to limit the number of query results, including take and limit methods. While they can both be used to limit the number of query results, they do have some subtle differences. In this article, we'll take a deep dive into how take and limit differ in Laravel, illustrating them with concrete code examples. First, let's look at the take method. The take method is part of Eloquent and is typically used for

What to do if node start reports an error What to do if node start reports an error Dec 29, 2022 pm 01:55 PM

Solution to node start error: 1. Execute "node xx.js" directly in the terminal; 2. Add start startup item "scripts": {"test": "echo \"Error: no test specified\" && exit 1 ","start":"node service.js"}"; 3. Re-execute "npm start".

What is the difference between link tag and import? What is the difference between link tag and import? Aug 28, 2023 am 11:19 AM

The differences between link tags and import include syntax and usage, functions and features, loading timing, compatibility and support, etc. Detailed introduction: 1. Syntax and usage. The link tag is an HTML tag, used to introduce external resources into HTML documents, such as CSS style sheets, JavaScript scripts, icons, etc. import is the module import syntax in ES6, used in JavaScript files. Introduce external modules; 2. Functions and features. The link tag can introduce a variety of resources, such as CSS style sheets, icons, etc.

How to use the limit and skip functions of Stream in Java for stream operations How to use the limit and skip functions of Stream in Java for stream operations Jun 26, 2023 pm 03:55 PM

StreamAPI was introduced in Java 8, which can greatly simplify the operation of collections. The Stream class provides many functional methods for operating on streams, including filtering, mapping, merging, and more. Among them, limit and skip are two functions used to limit the number of elements in stream operations. 1. Limit function The limit function is used to limit the number of elements in the stream. It accepts a long type parameter n, which represents the number of limits. After calling the limit function, a new stream is returned, which only contains

Comparison of functions and usage of take and limit in Laravel Comparison of functions and usage of take and limit in Laravel Mar 09, 2024 pm 09:09 PM

Take and limit are two commonly used methods in Laravel to limit the number of query result sets. Although they have certain similarities in functionality, they differ in usage and some details. This article will conduct a detailed comparison of the functions and usage of the two methods, and provide specific code examples to help readers better understand the differences between them and how to apply them correctly. 1.take method The take method is in the LaravelEloquent query builder

See all articles