hi guys...
i have two static value and between 8 and 16 other dynamic variables...which returns from sql queries everything.. like page titles, subjects etc...
everything based on number in tables,

Statics:  Language and Index 
Dynamic values: Categories from 1 to 6
                SubCategories from 1 to 10

system works like this

if language = 1 n index = 1 
   if  category = 1 
         if subcategory = 1 
              // code here 
        else if .......
               // code here
              // code here

if i do this in this way like repeating if circles, it ll take around 2000 rows... which means 50kb my question is how i can simplify this code as much as possible??

Thanks in advance

Edited 3 Years Ago by pyTony: fixed formatting

Deleted Member

Huh, if you have repetitive code use functions!

>it ll take around 2000 rows... which means 50kb

Where did you pick that random number from honey? (50kb) Nonsense!

148 posts and no sign of [code]

[/code] tags, oh dear.

i can calculate it don't worry... already i have 700 rows codes and its size is 24kb. make any sense now?
i m thinking about stored procedure or trigger in sql.

whats to point of using

unregistered users can already browse everything here... just saving 2seconds :p

putting the most likely candidate for the if statement close to the top of the statement may save time and processing power as once the if gets what it needs the rest of the statement is ignored. also when sorting through the categories the only code that would be executed would be contained in the if for that category so if your category was 1 then it would go something like this:

if($cat ==1) {

// do ifs for sub categories and such
}elseif($cat ==2) {
//stuff for cat 2

even if you have 18 main categories after 1 none of that would matter because if the category was 1 the if statment would stop there and the rest would be ignored. even though the size of the file is 50k it would be cut dramatically because not all the code would be processed. If this is the question you're asking

btw i m not newbie. i know how if circles works.
i have better algorithm than you thought, which is only 60 rows of code.

and even your code page 5kb or 500kb and $cat == 3 everything on the page will be checked until browser reaches the EOF.

and even your code page 5kb or 500kb and $cat == 3 everything on the page will be checked until browser reaches the EOF.

the browser only calls the php script, it doesn't execute it, the server does. The browser has nothing to do with it, only what the php script gives the browser is what is displayed

so... as i told you.. it download that 50 kbs.

If you are thinking in use stores procedures, sure is the best option. In this case, your aplicattion is not free from the engine of database.
Another way is using functions in external files. (using require o include)


i will see which would be the best. thnx

This article has been dead for over six months. Start a new discussion instead.