|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
|||
|
|||
|
Better way to do this
I know this code has ALOT going on.. so i would understand it loading like 5 times slower then the other pages... but instead it's timing out 9/10 of the time! what else can i do?
Search Page: Battle Search:<br><br></center> <form action="battlesearchaction.cfm" method="post"> Level Between: <input type="text" size="5" name="Level1"> - <input type="text" size="5" name="Level2"> <br><br> HP between: <input type="text" size="5" name="HP1"> - <input type="text" size="5" name="HP2"> <br><br> Alignment: <SELECT SIZE="1" NAME="align_name"> <OPTION VALUE="">Any</OPTION> <OPTION VALUE="Devil">Devil</OPTION><OPTION VALUE="Angel">Angel</OPTION></select><br><br> Alignment Between: <input type="text" size="5" name="Align1"> - <input type="text" size="5" name="Align2"><br><br> Pocket between: <input type="text" size="5" name="pocket1"> - <input type="text" size="5" name="pocket2"><br><br> Gender: <SELECT SIZE="1" NAME="gender"> <OPTION VALUE="">Any</OPTION> <OPTION VALUE="Male">Male</OPTION><OPTION VALUE="Female">Female</OPTION></select><br><br> <input type="submit" value="Search!"> Search Action: <cfparam name="form.Level1" default=""> <cfparam name="form.Level2" default=""> <cfparam name="form.HP1" default=""> <cfparam name="form.HP2" default=""> <cfparam name="form.align1" default=""> <cfparam name="form.align2" default=""> <cfparam name="form.pocket1" default=""> <cfparam name="form.pocket2" default=""> <cfquery name="get_user" datasource="aeris7282"> Select battle.user_level, battle.HP, battle.maxhp, battle.user_name, battle.user_ID, battle.alignment, battle.alignmentamount, finance.pocket, casual.user_gender From battle, finance, casual WHERE 0=0 AND battle.user_id = finance.user_ID AND casual.user_ID = battle.user_ID <cfif len(form.Level1)> AND user_Level >= #form.Level1# </cfif> <cfif len(form.Level2)> AND user_Level <= #form.Level2# </cfif> <cfif len(form.HP1)> AND HP >= '#form.HP1#' </cfif> <cfif len(form.HP2)> AND HP <= '#form.HP2#' </cfif> <cfif len(form.align1)> AND AlignmentAmount >= '#form.align1#' </cfif> <cfif len(form.align2)> AND AlignmentAmount <= '#form.align2#' </cfif> <cfif len(form.pocket1)> AND pocket >= '#form.pocket1#' </cfif> <cfif len(form.pocket2)> AND pocket <= '#form.pocket2#' </cfif> <cfif #form.align_name# is 'Any'> AND Alignment = 'Angel' OR Alignment = 'Devil' </cfif> <cfif #form.align_name# is 'Angel'> AND Alignment = 'Angel' </cfif> <cfif #form.align_name# is 'Devil'> AND Alignment = 'Devil' </cfif> <cfif #form.gender# is 'Any'> AND user_gender = 'Male' OR user_gender = 'Female' </cfif> <cfif #form.gender# is 'Male'> AND user_gender = 'Male' </cfif> <cfif #form.gender# is 'Female'> AND user_gender = 'Female' </cfif> </cfquery> <cfoutput query="get_user"> <b><a href="viewaccount.cfm?user_Id=#user_ID#">#User_name#</a></b> <br> <b>Max HP:</b> #maxhp#<br> <b>Status:</b> <cfif HP LTE '0'>Dead<cfelse>Alive</cfif> <br> <b>Alignment:</b> <cfif alignment is 'Angel'>Angel<cfelse>Devil</cfif><br> <b>Amount:</b> #alignmentamount#<br> | <a href="battles.cfm?user_ID=#user_ID#">Attack</a> | <a href="sendmail.cfm?user_ID=#user_ID#">Send Mail</a> |<br> <br> </cfoutput> |
|
#2
|
|||
|
|||
|
Unfortunately nothing jumps right out at me.
It is most likely the query that is slowing the page down. If you turn on CF debugging and check the data, it will show you how long it took to run the query (the time it actually makes it through) . If the query is slow, its a matter of tuning your sql, and data structure to perform better, If the query runs reasonably, the other possible suspect would be sheer volume of records returned/output. This may lead to an overly large page size. |
|
#3
|
|||
|
|||
|
Always separate data (queries, logic, etc.) from presentation and markup. I agree that the query is probably the cause of the timeout. You should be able to turn on debugging and see the execution time of any queries that ran during the request.
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian. How to Post a Question in the Forums |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ColdFusion Development > Better way to do this |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|