MX Looper Forum :: SQL query and Looper problem

This thread was displayed: 0 times


Starting with 17th May 2007, Adobe Systems will stop offering support for any version of the discontinued InterAKT products. As a result, we will not answer to new support incidents starting with May 17th, 2007. Pending support incidents will still be followed in order to be closed. The product forums will remain open and be transformed in user-to-user forums. The general forums will be made read-only and not allow new posts or comments.

For more information about the affected products visit: www.interaktonline.com/Support/

View Threaded Show descending
David Wilson
04-22-2007 17:46:10 GMT +2

My query and Looper script look like this:


$currentPage = $_SERVER["PHP_SELF"];

$maxRows_searchRs = 12;
$pageNum_searchRs = 0;
if (isset($_GET['pageNum_searchRs'])) {
  $pageNum_searchRs = $_GET['pageNum_searchRs'];
}
$startRow_searchRs = $pageNum_searchRs * $maxRows_searchRs;

$colname_searchRs = "-1";
if (isset($_POST['keyword1'])) {
  $colname_searchRs = (get_magic_quotes_gpc()) ? $_POST['keyword1'] : addslashes($_POST['keyword1']);
}
mysql_select_db($database_redstock, $redstock);
$query_searchRs = sprintf("SELECT * FROM images WHERE keywords LIKE CONCAT('%%', %s, '%%')", GetSQLValueString($colname_searchRs, "text"));
$query_limit_searchRs = sprintf("%s LIMIT %d, %d", $query_searchRs, $startRow_searchRs, $maxRows_searchRs);
$searchRs = mysql_query($query_limit_searchRs, $redstock) or die(mysql_error());
$row_searchRs = mysql_fetch_assoc($searchRs);

if (isset($_GET['totalRows_searchRs'])) {
  $totalRows_searchRs = $_GET['totalRows_searchRs'];
} else {
  $all_searchRs = mysql_query($query_searchRs);
  $totalRows_searchRs = mysql_num_rows($all_searchRs);
}
$totalPages_searchRs = ceil($totalRows_searchRs/$maxRows_searchRs)-1;

$queryString_searchRs = "";
if (!empty($_SERVER['QUERY_STRING'])) {
  $params = explode("&", $_SERVER['QUERY_STRING']);
  $newParams = array();
  foreach ($params as $param) {
    if (stristr($param, "pageNum_searchRs") == false &&
        stristr($param, "totalRows_searchRs") == false) {
      array_push($newParams, $param);
    }
  }
  if (count($newParams) != 0) {
    $queryString_searchRs = "&" . htmlentities(implode("&", $newParams));
  }
}
$queryString_searchRs = sprintf("&totalRows_searchRs=%d%s", $totalRows_searchRs, $queryString_searchRs);

The pagination Nav Bar doesn't work when the query uses 'LIKE', it only finds the first page and the other pages are blank. When I use "=" in the query the pagination works just fine.

Can you tell my why this is happening and what I can do to cure it, please?

Back | Reply | Quote | Top
Razvan Racasanu[InterAKT]Adobe Systems Romania staff
04-26-2007 15:19:50 GMT +2

Hello,

Can you attach an archive containing this page and the database dump so we can try and duplicate this problem?

Regards,
Razvan RACASANU

Reply | Quote | Top
© Adobe Systems Romania. All rights reserved.