php+mysql开发:
首先我批量选择了多条记录,现在要去批量生成(查询选择的这些记录)并将它们分别分页显示,最终分别打印各项记录通过点击页码选择!
我想这其中肯定要用到循环遍历等技术,但是本人不是很熟练,望得到大家的指教,谢谢

解决方案 »

  1.   

    [技巧] 完全讲解PHP+MySQL的分页显示示例分析I hope it would helpful.
      

  2.   

    这个跟查询语句有关, 有个 select * from [table] limit $(page-1) * $pagesize , $pagesize每次只显示这么多条语句, 然后新的就在新的一页里面显示。limit  这个查询词, 你可以去看看他的用法
      

  3.   

    批量选择就是加不同的搜索条件是么
    用if 就可以了
    if(isset($var1))
      $and = "where a = b";
    elseif(isset($var2))
      $and = "where a= b and a > 0";
    $sql = "select * from {$and}";类似这意思
      

  4.   

    smarty常用语句  2009-04-03 08:54:16|  分类: PHP |字号 订阅
    1 .include_once语句:引用文件路径,路径必需正确。   eg:include_once("smarty/Smarty.class.php");2 $smarty=new Smarty();新建一个对象smarty, 实例化一个对象。3 $smarty->template_dir=“”;指定$smarty对象使用的tpl模板的路径,它是一个目录,默认目录为当前的templates的目录,实际编程中,可能要指定目录。4 $smarty->compile_dir=””;指定$smarty对象的编译时的目录,就是smarty编译模板的目录,linux服务器,请你确认有可写可读权限。通常chmod -R 777 filename 修改权限,默认情况下它编译目录是当前的目录下的templates_c。5 $smarty->left_delimiter 与 $smarty->right_delimiter;查找模板变量左右的分割符,默认情况下为{ } 为了与script中括号相区别,通常写为<{ }>.6 $tp1->cache_dir=”./”;模板文件缓存的位置,Smarty最大的优点在于可以缓存,这里设置缓存的目录,默认情况下当前目录下的cache目录,同上,linux确保它的可读可写性。7 $smarty->cache-lifetime=60*60*24;这里以秒为单位计算缓存有效的时间,第一次缓存时间到期时Smarty的caching变量设置为true时缓存将被重建。-1表示建立缓存从不过期,为0时表示每次程度执行时缓存被重新建立,上述一天。8 $smarty->catching=true;缓存方式三个状态。0:Smarty'默认值,表示不对模板进行缓存。1:Smarty使用cache_lifetime来决定是否结束。2:表示Smarty将使用cache被建立时使用cache_lifetime这个值,习惯上用true和false来表示是否进行缓存。Smarty常用语法1.foreach : 循环简单数组,它是一个选择性的section循环.form指定循环的数组变量,item循环变量的名称,循环次数由from指定数组变量的个数决定。数组为空,执行<{foreachelse}>语句.格式如下:<{foreach from=$newsArray item=newID}>     The Id:<{$newsID.newsID}>     The Content:<{$newsID.newsTitle}><{foreachelse}>     No content to put<{/foreach}>2.section: 用于设计模板内的循环块。可完成foreach语句所完成所有的功能。Section的格式:<{section loop= $varName[,start=$start,step=$setp,max=$max,$show=true]}>name: section的名称,不用加$;$loop: 要循环的变量,程度中要使用assign对这个变量进行操作。$start: 开始循环的下标。默认为0;$step: 每次循环下标的增数;$show : boolean型。决定是否对于这块进行显示。默认为true;<{section}>的属性;index:循环下标。默认为0;index_prev:当前下标的上一个值,默认为-1;index_next:当前下标的下一个值,默认为1;first:是否为第一下循环;last:是否为最后一个循环;iteration:循环个数;rownum:当前行号,iteration的别名;loop:最后一个循环号。Section的循环次数;show:是否显示;<{section loop=$News}>     新闻编号:<{$News[loop].newID}><br>     新闻内容:<{$News[loop].newTitle}><br><{sectionelse}>     I am sorry<{/section}>对于一维数组:{section name=row loop=$list}{$list.name}{/section}对于二维数组:{section name=row loop=$list}{$list[row].name}{/section}另外还可以直接单一输出:     < { $commendList.0.infoType } >   < { $commendList.1.infoType } >对于三维数组:<{section name=cate loop=$myarray}><{section name=scate loop=$myarray[cate]}>id ------> <{$myarray[cate][scate].id}>title --------> <{$myarray[cate][scate].title}>url ----------> <{$myarray[cate][scate].url}><{/section}><{/section}>3.if用法:{if $list[row].name eq “1"}星期1{elseif $list[row].name==“2"}星期2{else}默认{/if}4.{ include file=a.template}<{include file=uhead.html}>5.Literal标签区域内的数据将被当作文本处理,此时模板将忽略其内部的所有字符信息. 该特性用于显示有可能包含大括号等字符信息的 javascript 脚本.<literal><script>alert('js');</script><literal>6.assign用于在模板被执行时为模板变量赋值.{assign var="name" value="Bob"}$smarty->assign("newsArray", $array);//编译并显示位于./templates下的index.tpl模板$smarty->display("example6.tpl");Smarty常用函数count_characters 计算变量里的字符数 {$articleTitle|count_characters}cat 将cat里的值连接到给定的变量后面. {$articleTitle|cat:" yesterday."}count_paragraphs计算变量里的段落数量。 {$articleTitle|count_paragraphs}count_sentences 计算变量里句子的数量。{$articleTitle|count_sentences}count_words 计算变量里的词数 。{$articleTitle|count_words}date_format格式化从函数strftime()获得的时间和日期。 {$yesterday|date_format:"%H:%M:%S"}default 为空变量设置一个默认值{$articleTitle|default:"no title"}escape 用于html等转码index.tpl:{$articleTitle}{$articleTitle|escape}{$articleTitle|escape:"html"} {* escapes & " ' < > *}{$articleTitle|escape:"htmlall"} {* escapes ALL html entities *}{$articleTitle|escape:"url"}{$articleTitle|escape:"quotes"}<a href="mailto:{$EmailAddress|escape:"hex"}">{$EmailAddress|escape:"hexentity"}</a>OUTPUT:'Stiff Opposition Expected to Casketless Funeral Plan'&#039;Stiff Opposition Expected to Casketless Funeral Plan&#039;&#039;Stiff Opposition Expected to Casketless Funeral Plan&#039;&#039;Stiff Opposition Expected to Casketless Funeral Plan&#039;%27Stiff+Opposition+Expected+to+Casketless+Funeral+Plan%27\'Stiff Opposition Expected to Casketless Funeral Plan\'<a href="mailto:%62%6f%62%40%6d%65%2e%6e%65%74">&#x62;&#x6f;&#x62;&#x40;&#x6d;&#x65;&#x2e;&#x6e;&#x65;&#x74;</a>indent 在每行缩进字符串,默认是4个字符{$articleTitle|indent:1:"\t"}lower 小写{$articleTitle|lower}nl2brregex_replace {$articleTitle|regex_replace:"/[\r\t\n]/":" "}replace {$articleTitle|replace:"被替换":"Vineyard"}spacify 每个字符间插入字符{$articleTitle|spacify:"^^"}string_format格式化字符串 {$number|string_format:"%.2f"}strip 用一个空格或一个给定字符替换所有重复空格,换行和制表符. {$articleTitle|strip:"&nbsp;"}strip_tags 去除<和>标签,包括在<和>之间的任何内容.{$articleTitle|strip_tags}truncateupper 大写wordwrap以指定段落的宽度,默认80.第二个参数,可以指定在约束点使用什么字符(默认是换行符\n).{$articleTitle|wordwrap:30:"\n":true}html_options<select name="media_id" id="media_id">        <{html_options options=$media_id selected=$ap.media_id}>   </select>html_radios<{html_radios name="is_valid" options=$is_valid checked=$ap.is_valid separator=" "}>
      

  5.   

    回复bing1215:批量选择的唯一标记是对应记录的ID,现在是要从数据库里面把这一批ID检索出来,要用到数组循环遍历,麻烦给出这句代码,谢谢