Help With PHP Code Snippet Because Scroll Moves


#1

New to PHP Code Snippets, but the Code Snippet that is a form on bottom of home page moves after requesting to view the next page results. Unsure what to do, to solve the problem.

This is the PHP Code Snippet:

<?php if (isset($_POST["languageSearch"]) || isset($_GET["languageSearch"])) { //Use wp global database object global $wpdb; if (isset($_POST["languageSearch"])) { $languageSearch=$_POST["languageSearch"]; //echo "The code setting POST is " . $languageSearch . "
"; unset($_POST["languageSearch"]); } if (isset($_GET["languageSearch"])) { $languageSearch=$_GET["languageSearch"]; //echo "The code setting GET is " . $languageSearch . "
"; unset($_GET["languageSearch"]); } echo ' '; if ($languageSearch==0) { $query = "SELECT * FROM `linkets` WHERE `approved` = 1 ORDER BY `linket_name`"; //echo "Get linkets ALL" . $languageSearch; } else { $query = "SELECT * FROM `linkets` WHERE `approved` = 1 AND `language`=$languageSearch ORDER BY `linket_name`"; //echo "Get linkets not ALL" . $languageSearch; } $customPagHTML = ""; $total_query = "SELECT COUNT(1) FROM (${query}) AS combined_table"; $total = $wpdb->get_var( $total_query ); $items_per_page = 25; $page = isset( $_GET['cpage'] ) ? abs( (int) $_GET['cpage'] ) : 1; $offset = ( $page * $items_per_page ) - $items_per_page; $results= $wpdb->get_results($query . "LIMIT ${offset}, ${items_per_page}" ); $totalPage = ceil($total / $items_per_page); echo ' '; foreach($results as $tableRow) { $linket = $tableRow->linket_name; $name = $tableRow->first_name . " " . $tableRow->last_name; echo ' '; } echo "
'; $languageQuery = "SELECT * FROM `language` ORDER BY `language_name`"; $languageResults= $wpdb->get_results($languageQuery); echo ""; echo""; echo"All Languages"; foreach($languageResults as $tableRowL) { if ($languageSearch == $tableRowL->language_id) { echo ' ' . $tableRowL->language_name . '
'; } else { echo ' ' . $tableRowL->language_name . '
'; } } echo "
"; echo "
"; echo '
'; echo ""; echo ""; echo ""; echo '
Linket Owner
' . $linket . ' ' . $name . '
"; if($totalPage > 1){ $customPagHTML = '
Page ' .$page. ' of ' .$totalPage. '   ' .paginate_links( array( 'base' => add_query_arg( array('cpage'=> ' %#% ' , 'languageSearch'=> $languageSearch, 'searchNames'=> $searchNames)), 'format' => '', 'prev_text' => __(' « '), 'next_text' => __(' » '), 'total' => $totalPage, 'current' => $page )).'
'; } echo $customPagHTML; } elseif (isset($_POST["searchNames"]) || isset($_GET["searchNames"])) { $searchNames = $_POST["searchNames"]; unset($_POST["searchNames"]); if (isset($_GET["searchNames"])) { $searchNames=$_GET["searchNames"]; //echo "The code setting GET is " . $searchNames . "
"; unset($_GET["searchNames"]); } //Use wp global database object global $wpdb; //echo "The search name setting is " . $searchNames; echo ' '; $query = "SELECT * FROM `linkets` WHERE `approved` =1 AND (`linket_name` LIKE '%$searchNames%' OR CONCAT_WS( ' ', `first_name` , `last_name` ) LIKE '%$searchNames%') ORDER BY `linket_name`"; $customPagHTML = ""; $total_query = "SELECT COUNT(1) FROM (${query}) AS combined_table"; $total = $wpdb->get_var( $total_query ); $items_per_page = 25; $page = isset( $_GET['cpage'] ) ? abs( (int) $_GET['cpage'] ) : 1; $offset = ( $page * $items_per_page ) - $items_per_page; $results= $wpdb->get_results($query . "LIMIT ${offset}, ${items_per_page}" ); $totalPage = ceil($total / $items_per_page); echo ' '; if ($total > 0) { foreach($results as $tableRow) { $linket = $tableRow->linket_name; $name = $tableRow->first_name . " " . $tableRow->last_name; echo ' '; } } else { echo ' '; } echo "
'; $languageQuery = "SELECT * FROM `language` ORDER BY `language_name`"; $languageResults= $wpdb->get_results($languageQuery); echo "
"; echo"
"; echo"All Languages
"; foreach($languageResults as $tableRowL) { echo ' ' . $tableRowL->language_name . '
'; } echo "Search Results
"; echo "
"; echo "
"; echo '
'; echo ""; echo ""; echo ""; echo '
Linket Owner
' . $linket . ' ' . $name . '
No search results.
"; if($totalPage > 1){ $customPagHTML = '
Page ' .$page. ' of ' .$totalPage. '   ' .paginate_links( array( 'base' => add_query_arg( array('cpage'=> ' %#% ' , 'languageSearch'=> $languageSearch, 'searchNames'=> $searchNames)), 'format' => '', 'prev_text' => __(' « '), 'next_text' => __(' » '), 'total' => $totalPage, 'current' => $page )).'
'; } echo $customPagHTML; } else { //Use wp global database object global $wpdb; //echo "The second code setting is " . $languageSearch . "
"; echo ' '; $customPagHTML = ""; //echo "Get linkets before pull-down" . $languageSearch; $query = "SELECT * FROM `linkets` WHERE `approved` = 1 ORDER BY `linket_name`"; $total_query = "SELECT COUNT(1) FROM (${query}) AS combined_table"; $total = $wpdb->get_var( $total_query ); $items_per_page = 25; $page = isset( $_GET['cpage'] ) ? abs( (int) $_GET['cpage'] ) : 1; $offset = ( $page * $items_per_page ) - $items_per_page; $results= $wpdb->get_results($query . "LIMIT ${offset}, ${items_per_page}" ); $totalPage = ceil($total / $items_per_page); echo ' '; foreach($results as $tableRow) { $linket = $tableRow->linket_name; $name = $tableRow->first_name . " " . $tableRow->last_name; echo ' '; } echo "
'; $languageQuery = "SELECT * FROM `language` ORDER BY `language_name`"; $languageResults= $wpdb->get_results($languageQuery); echo "
"; echo"
"; echo"All Languages
"; foreach($languageResults as $tableRowL) { echo ' ' . $tableRowL->language_name . '
'; } echo "
"; echo "
"; echo '
'; echo ""; echo ""; echo ""; echo '
Linket Owner
' . $linket . ' ' . $name . '
"; if($totalPage > 1){ $customPagHTML = '
Page ' .$page. ' of ' .$totalPage. '   ' .paginate_links( array( 'base' => add_query_arg( array('cpage'=> ' %#% ' , 'languageSearch'=> $languageSearch, 'searchNames'=> $searchNames)), 'format' => '', 'prev_text' => __(' « '), 'next_text' => __(' » '), 'total' => $totalPage, 'current' => $page )).'
'; } echo $customPagHTML; } ?>