RSS Forums RSS
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 714 | Replies: 8 | Thread Tools  Display Modes
Reply
Join Date: Sep 2007
Location: Budapest
Posts: 252
Reputation: fatihpiristine has a little shameless behaviour in the past 
Rep Power: 0
Solved Threads: 14
fatihpiristine's Avatar
fatihpiristine fatihpiristine is offline Offline
Posting Whiz in Training

Solution A Tricky Question for You!

  #1  
Nov 2nd, 2007
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
}
else
{
// 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
Do a favour, leave me alone
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Aug 2005
Posts: 4,844
Reputation: iamthwee is a glorious beacon of light iamthwee is a glorious beacon of light iamthwee is a glorious beacon of light iamthwee is a glorious beacon of light iamthwee is a glorious beacon of light 
Rep Power: 17
Solved Threads: 325
iamthwee's Avatar
iamthwee iamthwee is offline Offline
Industrious Poster

Re: A Tricky Question for You!

  #2  
Nov 2nd, 2007
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.
Last edited by iamthwee : Nov 2nd, 2007 at 4:00 pm.
*Voted best profile in the world*
Reply With Quote  
Join Date: Sep 2007
Location: Budapest
Posts: 252
Reputation: fatihpiristine has a little shameless behaviour in the past 
Rep Power: 0
Solved Threads: 14
fatihpiristine's Avatar
fatihpiristine fatihpiristine is offline Offline
Posting Whiz in Training

Re: A Tricky Question for You!

  #3  
Nov 2nd, 2007
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
Do a favour, leave me alone
Reply With Quote  
Join Date: Aug 2006
Posts: 32
Reputation: StatiX is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 2
StatiX's Avatar
StatiX StatiX is offline Offline
Light Poster

Re: A Tricky Question for You!

  #4  
Nov 3rd, 2007
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
etc...

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
Always do what you wish you could..
Reply With Quote  
Join Date: Sep 2007
Location: Budapest
Posts: 252
Reputation: fatihpiristine has a little shameless behaviour in the past 
Rep Power: 0
Solved Threads: 14
fatihpiristine's Avatar
fatihpiristine fatihpiristine is offline Offline
Posting Whiz in Training

Re: A Tricky Question for You!

  #5  
Nov 4th, 2007
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.
Do a favour, leave me alone
Reply With Quote  
Join Date: Aug 2006
Posts: 32
Reputation: StatiX is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 2
StatiX's Avatar
StatiX StatiX is offline Offline
Light Poster

Re: A Tricky Question for You!

  #6  
Nov 4th, 2007
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
Always do what you wish you could..
Reply With Quote  
Join Date: Sep 2007
Location: Budapest
Posts: 252
Reputation: fatihpiristine has a little shameless behaviour in the past 
Rep Power: 0
Solved Threads: 14
fatihpiristine's Avatar
fatihpiristine fatihpiristine is offline Offline
Posting Whiz in Training

Re: A Tricky Question for You!

  #7  
Nov 4th, 2007
so... as i told you.. it download that 50 kbs.
Do a favour, leave me alone
Reply With Quote  
Join Date: Sep 2007
Location: Buenos Aires
Posts: 30
Reputation: chmazur is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 2
chmazur's Avatar
chmazur chmazur is offline Offline
Light Poster

Re: A Tricky Question for You!

  #8  
Nov 4th, 2007
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)

ch.-
Reply With Quote  
Join Date: Sep 2007
Location: Budapest
Posts: 252
Reputation: fatihpiristine has a little shameless behaviour in the past 
Rep Power: 0
Solved Threads: 14
fatihpiristine's Avatar
fatihpiristine fatihpiristine is offline Offline
Posting Whiz in Training

Re: A Tricky Question for You!

  #9  
Nov 4th, 2007
i will see which would be the best. thnx
Do a favour, leave me alone
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.



Similar Threads
Other Threads in the PHP Forum
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 3:00 am.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC