[ic] More Listing

kyle@invisio.com kyle@invisio.com
Mon, 07 May 2001 13:21:11 -0400


At 03:23 PM 5/7/01 , you wrote:
>Is it possible to use a more list when doing a [query] call.  
>meaning query something like select * from product where color = 'red'
>Then use a more list to allow the user to navigate through the pages.

If you are using query, then you need to control the paging system
with LIMIT in your SQL query.

You would have to use IC search capability to be able to use the
paging features in IC.


Kyle (KC)

PS: If your comfortable with calc tags maybe this will give you some ideas
for query paging (not complete but gives you an idea):

[calc]
# number of results per page
$paging = 25;
# set your sql from statement here
# probably using input from a form etc...
$sql = "FROM product where color = 'red'";
$limit = ' [value limit]' || '0';
$sql_limit =  $sql . " LIMIT $limit,".$paging;
return '';
[/calc]

[query list=1 sql="SELECT code,ETC [calc]$sql_limit[/calc]"]
Do your thing here to display what you want.<br>
item [sql-param code]<br>
[/query]


[comment]Below I used a drop down to select a page range to display,
but you could set up links, just be sure to pass along limit
in the link. [/comment]

[query list=1 sql="SELECT count(*) AS junk [calc]$sql[/calc]"]
[calc]$numrows = '[sql-param junk]'; return '';[/calc]
[/query]


<FORM ACTION="[process]" METHOD=POST>
<INPUT TYPE=hidden NAME=mv_todo  VALUE=return>
<INPUT TYPE=hidden NAME=mv_nextpage VALUE="YOURPAGE">
[calc]
$out = $numrows . ' Matches found';
$page = 0;
if ($numrows > $paging) {
 $out .= ', displaying range:<SELECT NAME="limit">';
 $pages = $numrows/25;
 while ($page < $pages) {
  $val = $page * $paging;
  $sel = ($val eq '[value limit]') ? " selected" : "";
  $low = $val + 1;
  $hi = $low + $paging - 1;
  $hi = ($hi < $numrows) ? $hi : $numrows;
  $out .= "<option value=\"$val\"$sel>Pages: $low - $hi\n";
  $page++;
 }
 $out .= '</select>
 <input type="Submit" name="submit" value="Show Range">';
}
return $out;
[/calc]
</form>