扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
作者:Sean Kelly 来源:IBM 2007年10月21日
关键字:
// Append navigation $output = '<h4>Showing items ' . $limit_start . '-' . min($limit_start + $limit_step - 1, count($images)) . ' of ' . count($images) . '<br />'; $prev_start = max(0, $limit_start - $limit_step); if ( $limit_start > 0 ) { $output .= get_table_link('<<', 0, $limit_step); $output .= ' | ' . get_table_link('Prev', $prev_start, $limit_step); } else { $output .= '<< | Prev'; } // Append next button $next_start = min($limit_start + $limit_step, count($images)); if ( $limit_start + $limit_step < count($images) ) { $output .= ' | ' . get_table_link('Next',$next_start, $limit_step); $output .= ' | ' . get_table_link('>>',(count($images) - $limit_step), $limit_step); } else { $output .= ' | Next | >>'; } $output .= '</h4>'; |
function get_table_link ( $title, $start, $step ) { $link = "index.php?start=$start&step=$step"; return '<a href="' . $link . '">' . $title .'</a>'; } function get_image_link ( $title, $index ) { $link = "expand.php?index=$index"; return '<a href="' . $link . '">' . $title . '</a>'; } |
function get_image ( $index ) { $images = get_image_list ( 'images' ); // Generate navigation $output .= '<img src="images/' . $images[$index] . '" />'; return $output; } |
$output .= '<h4>Viewing image ' . $index .' of ' . count($images) . '<br />'; if ( $index > 0 ) { $output .= get_image_link('<<', 0); $output .= ' | ' . get_image_link('Prev', $index-1); } else { $output .= '<< | Prev'; } $output .= ' | ' . get_table_link('Up', $index, 5); if ( $index < count($images) ) { $output .= ' | ' . get_image_link('Next', $index+1); $output .= ' | ' . get_image_link('>>', count($images)); } else { $output .= ' | Next | >>'; } $output .= '</h4>'; |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/2000/REC-xhtml1-20000126/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Creating a simple picture album viewer</title> <style type="text/css"> body { text-align: center } table.image_table { margin: 0 auto 0 auto; width: 700px; padding:10px; border: 1px solid #ccc; background: #eee; } table.image_table td { padding: 5px } table.image_table a { display: block; } table.image_table img { display: block; width: 120px; padding: 2px; border: 1px solid #ccc; } </style> </head> <body> <h1>Creating a simple picture album viewer</h1> <?php $index = isset($_REQUEST['index']) ? $_REQUEST['index'] : 0; echo get_image($index); ?> </body> </html> |
![]() 图 2. 完成的相册 |
婵犵鈧啿鈧綊鎮樻径鎰畺闁靛ň鏅滄慨婊堟偨椤栨稓鎽冮柟鐑╂櫊瀹曟岸宕堕埡鍌滄殸闂佽鍨伴崢鏍姳閿涘嫭鍠嗘い銈呭姬婵☆偅婢樺Λ妤呮偂濞嗘挸瀚夐柍褜鍓熷顒侊紣娓氣偓閻涙捇鏌涘┑鍛樂缂佹鐭傞獮搴ㄥ焵椤掑嫬瀚夋い鏍ㄧ懁缁诲棝鏌熼褍鐏茬紒杈ㄧ箞閺屽洭鏁愰崟顓犳澖闁荤姳闄嶉崹钘壩i崟顖涘殜闁硅泛顫曢埀顒€锕︾槐鏃堝箣閻愬弬妤呮煛閸偄鐏﹂柛瀣墬缁傛帞鎹勯搹瑙勵啈闂佸搫瀚烽崹閬嶅磻瀹ュ鍎嶉柛鏇ㄥ墯娴犳ê霉閿濆棗鈻曢柍褜鍓氶弻銊ф閻愬鈻曢悗锝傛櫇椤忛亶鏌曢崱顓熷
现场直击|2021世界人工智能大会
直击5G创新地带,就在2021MWC上海
5G已至 转型当时——服务提供商如何把握转型的绝佳时机
寻找自己的Flag
华为开发者大会2020(Cloud)- 科技行者