Reply
PHP Question - Recordset issue
Old 02-02-2005, 06:57 AM PHP Question - Recordset issue
Junior Talker

Posts: 4
I have built an advanced search page that almost does everything i want .
The problem i am having is with recordset paging.

When i run a search the first page of records is fine but when i click next page the sql query is getting messed up.

I am pretty sure the issue is with this part of the code as the select menu from the search page is passing accross the variable.

PHP Code:
 // Category
if ( !empty($Category) && $Category == 'all' ) {
;
}
else {
         
$SQLQUERY .= "AND CategoryId = '$Category'"
          } 
This is the output of the query when it goes wonky
Quote:
SELECT * FROM offers INNER JOIN offertypes ON (offers.OfferType = offertypes.OfferTypeId) WHERE OfferId >= 1 AND OfferType = ''AND CategoryId = ''
Any Ideas?
__________________
Please direct all questions, complaints, messages, words of wisdom, assertions, suggestions and general chat - elsewhere!
Andalucia Web Design - Web Design Services and discount hosting.
nostro is offline
Reply With Quote
View Public Profile Visit nostro's homepage!
 
When You Register, These Ads Go Away!
     
Old 02-02-2005, 07:04 AM Thought I wouldpost rest of code in case it helps!!
Junior Talker

Posts: 4
PHP Code:
<?php  
 
//Declare Form Variables

$KeyWords=$_POST['KeyWords'];
$SiteName=$_POST['SiteName'];
$OfferType=$_POST['OfferType'];
$OfferPriceMin=$_POST['OfferPriceMin'];
$OfferPriceMax=$_POST['OfferPriceMax'];
$LengthOfTrial=$_POST['LengthOfTrial'];
$PPMin=$_POST['PPMin'];
$PPMax=$_POST['PPMax'];
$Category=$_POST['Category'];
$Rating=$_POST['Rating'];

// SQL Query
$SQLQUERY " ";?>
<?php 
// KeyWords
if ($KeyWords!= "") {
    
$SQLQUERY .= "AND Description REGEXP '$KeyWords'";
}
else {
     ; 
          }
        
// SiteName
if ($SiteName!= "") {
$SQLQUERY .= "AND SiteName REGEXP '$SiteName'";
}
else {
          ;
          }  
        
// OfferType
if ( !empty($OfferType) && $OfferType == 'all' ) {
 ;   
}
else {
    
$SQLQUERY .= "AND OfferType = '$OfferType'";  
          }  
          
// OfferPriceMin
if ($OfferPriceMin!= "") {
 
$SQLQUERY .= "AND OfferPrice >= '$OfferPriceMin'";
}
else {
       ;  
          }
          
// OfferPriceMax
if ($OfferPriceMax!= "") {
$SQLQUERY .= "AND OfferPrice <= '$OfferPriceMax'";
}
else {
      ;    
          }
         
          
// PPMin
if ($PPMin!= "") {
$SQLQUERY .= "AND PricePerMonth >= '$PPMin'";
}
else {
       ;   
          }
          
// PPMAx
if ($PPMax!= "") {
$SQLQUERY .= "AND PricePerMonth <= '$PPMax'";
}
else {
       ;   
          }

         
// Category
if ( !empty($Category) && $Category == 'all' ) {
;
}
else {
         
$SQLQUERY .= "AND CategoryId = '$Category'"
          }
  
          
          
// Rating
if ($Rating!= ""){
$SQLQUERY .= "AND Rating >= '$Rating'";
}
else {
          ;
          }
// begin Recordset
$maxRows_RsSites 10;
$pageNum_RsSites 0;
if (isset(
$HTTP_GET_VARS['pageNum_RsSites'])) {
  
$pageNum_RsSites $HTTP_GET_VARS['pageNum_RsSites'];
}
$startRow_RsSites $pageNum_RsSites $maxRows_RsSites;
$query_RsSites =  ("SELECT * FROM offers INNER JOIN offertypes ON (offers.OfferType = offertypes.OfferTypeId) WHERE OfferId >= 1 "$SQLQUERY);
$RsSites $Crazy->SelectLimit($query_RsSites$maxRows_RsSites$startRow_RsSites) or die($Crazy->ErrorMsg());
if (isset(
$HTTP_GET_VARS['totalRows_RsSites'])) {
  
$totalRows_RsSites $HTTP_GET_VARS['totalRows_RsSites'];
} else {
  
$all_RsSites $Crazy->SelectLimit($query_RsSites) or die($Crazy->ErrorMsg());
  
$totalRows_RsSites $all_RsSites->RecordCount();
}
$totalPages_RsSites = (int)(($totalRows_RsSites-1)/$maxRows_RsSites);
// end Recordset

// rebuild the query string by replacing pageNum and totalRows with the new values
$queryString_RsSites KT_removeParam("&" . @$HTTP_SERVER_VARS['QUERY_STRING'], "pageNum_RsSites");
$queryString_RsSites KT_replaceParam($queryString_RsSites"totalRows_RsSites"$totalRows_RsSites);
__________________
Please direct all questions, complaints, messages, words of wisdom, assertions, suggestions and general chat - elsewhere!
Andalucia Web Design - Web Design Services and discount hosting.
nostro is offline
Reply With Quote
View Public Profile Visit nostro's homepage!
 
Reply     « Reply to PHP Question - Recordset issue
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.12040 seconds with 13 queries