X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Changing design (https://forum.x-cart.com/forumdisplay.php?f=51)
-   -   {section} How to end section loop early.... (https://forum.x-cart.com/showthread.php?t=8080)

garryhs 06-14-2004 07:51 AM

{section} How to end section loop early....
 
Hi all,

I have a section that is looping through 1000's of records. When I find what I want, how do I exit the loop. ???

Any ideas ? As I cacnot seem to find anything on this.

Example:

Array is $test

{section name=test loop=$test}
{if $test[test] eq $my_parm}
then I want to exit the loop ! How ?
{/if}
{/section}

Any info would be great.

shan 06-14-2004 04:39 PM

Array is $test

Code:

{section name=test_num loop=$test}

{if $test[test_num].param eq $my_parm}

$test[test_num].param

{/if}

{/section}


That code will only print the row in the loop that matches your $my_param.

not sure if thats what your looking for.

the loop would be made up from a php file / mysql statement and the {if} statement will pick out the row you want.

If you wanted to minimise the amount of rows in the array you would need to alter the sql statement

garryhs 06-14-2004 10:14 PM

Issues with {section} processing time...
 
Hi,

Basically that is what I am doing.

I just want to exit the loop once I have what I want as to minimize processing time.

The way I have coded it. It works, but it is slow on large databases, just want to work out of a way of dropping out of the section once the if condition is met.

Any ideas...

TelaFirma 06-15-2004 03:45 AM

I would suggest filtering at the PHP level, either by the WHERE clause in you DB query (preferably), or by using foreach and if/then loops in PHP.

Processing time will be MUCH shorter.


All times are GMT -8. The time now is 07:33 PM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.