Php Algorithms cannot be understood. please explain them one by one! Urgent $ MM_paramName = & quot ;;? // *** GoToRecordandMoveToRecord: the createstringsformaintainingURLandFormparam php algorithm cannot be understood. please explain it one by one! Urgent
$ MM_paramName = "";?
// *** Go To Record and Move To Record: create strings for maintaining URL and Form parameters
// Create the list of parameters which shocould not be maintained
$ MM_removeList = "& index = ";
If ($ MM_paramName! = "") $ MM_removeList. = "&". strtolower ($ MM_paramName). "= ";
$ MM_keepURL = "";
$ MM_keepForm = "";
$ MM_keepBoth = "";
$ MM_keepNone = "";
// Add the URL parameters to the MM_keepURL string
Reset ($ HTTP_GET_VARS );
While (list ($ key, $ val) = each ($ HTTP_GET_VARS )){
$ NextItem = "&". strtolower ($ key). "= ";
If (! Stristr ($ MM_removeList, $ nextItem )){
$ MM_keepURL. = "&". $ key. "=". urlencode ($ val );
}
}
// Add the URL parameters to the MM_keepURL string
If (isset ($ HTTP_POST_VARS )){
Reset ($ HTTP_POST_VARS );
While (list ($ key, $ val) = each ($ HTTP_POST_VARS )){
$ NextItem = "&". strtolower ($ key). "= ";
If (! Stristr ($ MM_removeList, $ nextItem )){
$ MM_keepForm. = "&". $ key. "=". urlencode ($ val );
}
}
}
// Create the Form + URL string and remove the intial '&' from each of the strings
$ MM_keepBoth = $ MM_keepURL. "&". $ MM_keepForm;
If (strlen ($ MM_keepBoth)> 0) $ MM_keepBoth = substr ($ MM_keepBoth, 1 );
If (strlen ($ MM_keepURL)> 0) $ MM_keepURL = substr ($ MM_keepURL, 1 );
If (strlen ($ MM_keepForm)> 0) $ MM_keepForm = substr ($ MM_keepForm, 1 );
------ Solution --------------------
Concatenate the GET and POST parameters into the GET parameters to form a URL called MM_keepBoth. & key = val, so one more string starts &, and must be deleted by substr.
------ Solution --------------------
Let's try it.
PHP code
$ MM_paramName = ""; // *** Go To Record and Move To Record: create strings for maintaining URL and Form parameters // create the list of parameters which shocould not be maintained $ MM_removeList = "& index ="; if ($ MM_paramName! = "") $ MM_removeList. = "&". strtolower ($ MM_paramName ). "="; $ MM_keepURL = ""; $ MM_keepForm = ""; $ MM_keepBoth = ""; $ MM_keepNone = ""; // add the URL parameters to the MM_keepURL stringreset ($ HTTP_GET_VARS); // $ HTTP_GET_VARS is equivalent to $ _ GET. In early versions of php3/4, $ HTTP_GET_VARS was used, but later versions of $ HTTP_GET_VARS were discarded. Use $ _ GET instead. While (list ($ key, $ val) = each ($ HTTP_GET_VARS) {// traverse each item in the array, key = $ key, value = $ val $ nextItem = "&". strtolower ($ key ). "="; if (! Stristr ($ MM_removeList, $ nextItem) {// If MM_removeList does not exist $ nextItem $ MM_keepURL. = "&". $ key. "= ". urlencode ($ val); // connection string} // add the URL parameters to the MM_keepURL stringif (isset ($ HTTP_POST_VARS )) {// $ HTTP_POST_VARS is the same as $ HTTP_GET_VARSreset ($ HTTP_POST_VARS); // reset $ HTTP_POST_VARS to return its pointer to 0 while (list ($ key, $ val) = each ($ HTTP_POST_VARS) {// traversal, same as $ nextItem = "&". strtolower ($ key ). "="; // connection string if (! Stristr ($ MM_removeList, $ nextItem) {// same as $ MM_keepForm. = "&". $ key. "= ". urlencode ($ val); // same as above} // create the Form + URL string and remove the intial '&' from each of the strings $ MM_keepBoth = $ MM_keepURL. "&". $ MM_keepForm; if (strlen ($ MM_keepBoth)> 0) $ MM_keepBoth = substr ($ MM_keepBoth, 1); // if the length of $ MM_keepBoth is greater than 0, truncate from 1 byte to the end if (strlen ($ MM_keepURL)> 0) $ MM_keepURL = substr ($ MM_keepURL, 1 ); // similar to above if (strlen ($ MM_keepForm)> 0) $ MM_keepForm = substr ($ MM_keepForm, 1); // similar to above