How can I do this sql filter results












0














I have an website there are 5 categories, i only want to show the 1-4 category only in the new posts..how can I edit the code to do this job? thanks



Here is my code, and I do that in my sql by using following code:



 SELECT * FROM `ff_se` WHERE Wid in ('1','2','3','4')"


but i dont know how to do that in php code. following is my part of php code:



$this->TableSe = 'ff_se';
$this->TableSeWord = 'ff_se_word';
$this->TableSeSupport = 'ff_se_support';
$this->TableSePost = 'ff_se_post';
$this->TableSePostTableId = 'ff_se_post_tableid';

public function GetAjaxList($Get){
$Results = array();
$Get = $this->StrToGBK($Get);
$Page = $Get['page'] ? intval($Get['page']):0;

$Where = '';
$Order = 'S.updateline';
if($Get['type'] == 'New'){
$Order = 'S.dateline';
}else if($Get['type'] == 'Hot'){
$Order = 'S.updateline';
if($this->Config['PluginVar']['ListHotVal']){
$Where .= ' and (S.support_count >= '.$this->Config['PluginVar']['ListHotVal'].' OR S.comment_count >= '.$this->Config['PluginVar']['ListHotVal'].')';
}
if($this->Config['PluginVar']['ListHotDataline']){
$Where .= ' and S.dateline >= '.strtotime("-".$this->Config['PluginVar']['ListHotDataline']." hours",time());
}
}else if($Get['type'] == 'Nearby'){//
$Order = 'S.updateline';
if($Get['lng'] && $Get['lat']){
$SquarePoint = $this->GetReturnSquarePoint($Get['lng'],$Get['lat'],$this->Config['PluginVar']['Distance']);
$Where .= ' and S.lat <> 0 and S.lat > '.$SquarePoint['right-bottom']['lat'].' and S.lat < '.$SquarePoint['left-top']['lat'].' and S.lng > '.$SquarePoint['left-top']['lng'].' and S.lng < '.$SquarePoint['right-bottom']['lng'];
}else{
return $Results;
}
}

if($_GET['wid']){
$Where .= ' and S.wid = '.intval($_GET['wid']);
}
$Where .= ' and S.display = 1 and S.fast_add_display = 1';
$Where = preg_replace('/and/','where',$Where,1);

$this->Config['PluginVar']['ListNum'] = $this->Config['PluginVar']['ListNum'] ? $this->Config['PluginVar']['ListNum'] : 10;
$Limit = 'LIMIT '.($Page * $this->Config['PluginVar']['ListNum']).','.$this->Config['PluginVar']['ListNum'];

$FetchSql = 'SELECT W.title as Ttitle,S.* FROM '.DB::table($this->Tablese).' S LEFT JOIN '.DB::table($this->TableSeWord).' W on W.id = S.wid '.$Where .' order by topdateline > '.time().' desc,'.$Order.' desc,S.dateline desc '.$Limit;
$Results = $this->ListFormat(DB::fetch_all($FetchSql));
return $Results;
}









share|improve this question




















  • 1




    ..i dont know how to do that in php code... Why doing this in both? You said mysql is working ... why php?
    – B001ᛦ
    Nov 12 '18 at 12:35












  • @B001ᛦ he wants to do it using PHP. the same thing he has done using MySQL. He wants to know where he can use the same query in his PHP code and replace the old query.
    – Sayed Mohd Ali
    Nov 12 '18 at 12:37












  • yes...i wants to do it using PHP. the same thing he has done using MySQL. I wants to know where he can use the same query in his PHP code and replace the old query
    – Leung
    Nov 12 '18 at 13:32


















0














I have an website there are 5 categories, i only want to show the 1-4 category only in the new posts..how can I edit the code to do this job? thanks



Here is my code, and I do that in my sql by using following code:



 SELECT * FROM `ff_se` WHERE Wid in ('1','2','3','4')"


but i dont know how to do that in php code. following is my part of php code:



$this->TableSe = 'ff_se';
$this->TableSeWord = 'ff_se_word';
$this->TableSeSupport = 'ff_se_support';
$this->TableSePost = 'ff_se_post';
$this->TableSePostTableId = 'ff_se_post_tableid';

public function GetAjaxList($Get){
$Results = array();
$Get = $this->StrToGBK($Get);
$Page = $Get['page'] ? intval($Get['page']):0;

$Where = '';
$Order = 'S.updateline';
if($Get['type'] == 'New'){
$Order = 'S.dateline';
}else if($Get['type'] == 'Hot'){
$Order = 'S.updateline';
if($this->Config['PluginVar']['ListHotVal']){
$Where .= ' and (S.support_count >= '.$this->Config['PluginVar']['ListHotVal'].' OR S.comment_count >= '.$this->Config['PluginVar']['ListHotVal'].')';
}
if($this->Config['PluginVar']['ListHotDataline']){
$Where .= ' and S.dateline >= '.strtotime("-".$this->Config['PluginVar']['ListHotDataline']." hours",time());
}
}else if($Get['type'] == 'Nearby'){//
$Order = 'S.updateline';
if($Get['lng'] && $Get['lat']){
$SquarePoint = $this->GetReturnSquarePoint($Get['lng'],$Get['lat'],$this->Config['PluginVar']['Distance']);
$Where .= ' and S.lat <> 0 and S.lat > '.$SquarePoint['right-bottom']['lat'].' and S.lat < '.$SquarePoint['left-top']['lat'].' and S.lng > '.$SquarePoint['left-top']['lng'].' and S.lng < '.$SquarePoint['right-bottom']['lng'];
}else{
return $Results;
}
}

if($_GET['wid']){
$Where .= ' and S.wid = '.intval($_GET['wid']);
}
$Where .= ' and S.display = 1 and S.fast_add_display = 1';
$Where = preg_replace('/and/','where',$Where,1);

$this->Config['PluginVar']['ListNum'] = $this->Config['PluginVar']['ListNum'] ? $this->Config['PluginVar']['ListNum'] : 10;
$Limit = 'LIMIT '.($Page * $this->Config['PluginVar']['ListNum']).','.$this->Config['PluginVar']['ListNum'];

$FetchSql = 'SELECT W.title as Ttitle,S.* FROM '.DB::table($this->Tablese).' S LEFT JOIN '.DB::table($this->TableSeWord).' W on W.id = S.wid '.$Where .' order by topdateline > '.time().' desc,'.$Order.' desc,S.dateline desc '.$Limit;
$Results = $this->ListFormat(DB::fetch_all($FetchSql));
return $Results;
}









share|improve this question




















  • 1




    ..i dont know how to do that in php code... Why doing this in both? You said mysql is working ... why php?
    – B001ᛦ
    Nov 12 '18 at 12:35












  • @B001ᛦ he wants to do it using PHP. the same thing he has done using MySQL. He wants to know where he can use the same query in his PHP code and replace the old query.
    – Sayed Mohd Ali
    Nov 12 '18 at 12:37












  • yes...i wants to do it using PHP. the same thing he has done using MySQL. I wants to know where he can use the same query in his PHP code and replace the old query
    – Leung
    Nov 12 '18 at 13:32
















0












0








0







I have an website there are 5 categories, i only want to show the 1-4 category only in the new posts..how can I edit the code to do this job? thanks



Here is my code, and I do that in my sql by using following code:



 SELECT * FROM `ff_se` WHERE Wid in ('1','2','3','4')"


but i dont know how to do that in php code. following is my part of php code:



$this->TableSe = 'ff_se';
$this->TableSeWord = 'ff_se_word';
$this->TableSeSupport = 'ff_se_support';
$this->TableSePost = 'ff_se_post';
$this->TableSePostTableId = 'ff_se_post_tableid';

public function GetAjaxList($Get){
$Results = array();
$Get = $this->StrToGBK($Get);
$Page = $Get['page'] ? intval($Get['page']):0;

$Where = '';
$Order = 'S.updateline';
if($Get['type'] == 'New'){
$Order = 'S.dateline';
}else if($Get['type'] == 'Hot'){
$Order = 'S.updateline';
if($this->Config['PluginVar']['ListHotVal']){
$Where .= ' and (S.support_count >= '.$this->Config['PluginVar']['ListHotVal'].' OR S.comment_count >= '.$this->Config['PluginVar']['ListHotVal'].')';
}
if($this->Config['PluginVar']['ListHotDataline']){
$Where .= ' and S.dateline >= '.strtotime("-".$this->Config['PluginVar']['ListHotDataline']." hours",time());
}
}else if($Get['type'] == 'Nearby'){//
$Order = 'S.updateline';
if($Get['lng'] && $Get['lat']){
$SquarePoint = $this->GetReturnSquarePoint($Get['lng'],$Get['lat'],$this->Config['PluginVar']['Distance']);
$Where .= ' and S.lat <> 0 and S.lat > '.$SquarePoint['right-bottom']['lat'].' and S.lat < '.$SquarePoint['left-top']['lat'].' and S.lng > '.$SquarePoint['left-top']['lng'].' and S.lng < '.$SquarePoint['right-bottom']['lng'];
}else{
return $Results;
}
}

if($_GET['wid']){
$Where .= ' and S.wid = '.intval($_GET['wid']);
}
$Where .= ' and S.display = 1 and S.fast_add_display = 1';
$Where = preg_replace('/and/','where',$Where,1);

$this->Config['PluginVar']['ListNum'] = $this->Config['PluginVar']['ListNum'] ? $this->Config['PluginVar']['ListNum'] : 10;
$Limit = 'LIMIT '.($Page * $this->Config['PluginVar']['ListNum']).','.$this->Config['PluginVar']['ListNum'];

$FetchSql = 'SELECT W.title as Ttitle,S.* FROM '.DB::table($this->Tablese).' S LEFT JOIN '.DB::table($this->TableSeWord).' W on W.id = S.wid '.$Where .' order by topdateline > '.time().' desc,'.$Order.' desc,S.dateline desc '.$Limit;
$Results = $this->ListFormat(DB::fetch_all($FetchSql));
return $Results;
}









share|improve this question















I have an website there are 5 categories, i only want to show the 1-4 category only in the new posts..how can I edit the code to do this job? thanks



Here is my code, and I do that in my sql by using following code:



 SELECT * FROM `ff_se` WHERE Wid in ('1','2','3','4')"


but i dont know how to do that in php code. following is my part of php code:



$this->TableSe = 'ff_se';
$this->TableSeWord = 'ff_se_word';
$this->TableSeSupport = 'ff_se_support';
$this->TableSePost = 'ff_se_post';
$this->TableSePostTableId = 'ff_se_post_tableid';

public function GetAjaxList($Get){
$Results = array();
$Get = $this->StrToGBK($Get);
$Page = $Get['page'] ? intval($Get['page']):0;

$Where = '';
$Order = 'S.updateline';
if($Get['type'] == 'New'){
$Order = 'S.dateline';
}else if($Get['type'] == 'Hot'){
$Order = 'S.updateline';
if($this->Config['PluginVar']['ListHotVal']){
$Where .= ' and (S.support_count >= '.$this->Config['PluginVar']['ListHotVal'].' OR S.comment_count >= '.$this->Config['PluginVar']['ListHotVal'].')';
}
if($this->Config['PluginVar']['ListHotDataline']){
$Where .= ' and S.dateline >= '.strtotime("-".$this->Config['PluginVar']['ListHotDataline']." hours",time());
}
}else if($Get['type'] == 'Nearby'){//
$Order = 'S.updateline';
if($Get['lng'] && $Get['lat']){
$SquarePoint = $this->GetReturnSquarePoint($Get['lng'],$Get['lat'],$this->Config['PluginVar']['Distance']);
$Where .= ' and S.lat <> 0 and S.lat > '.$SquarePoint['right-bottom']['lat'].' and S.lat < '.$SquarePoint['left-top']['lat'].' and S.lng > '.$SquarePoint['left-top']['lng'].' and S.lng < '.$SquarePoint['right-bottom']['lng'];
}else{
return $Results;
}
}

if($_GET['wid']){
$Where .= ' and S.wid = '.intval($_GET['wid']);
}
$Where .= ' and S.display = 1 and S.fast_add_display = 1';
$Where = preg_replace('/and/','where',$Where,1);

$this->Config['PluginVar']['ListNum'] = $this->Config['PluginVar']['ListNum'] ? $this->Config['PluginVar']['ListNum'] : 10;
$Limit = 'LIMIT '.($Page * $this->Config['PluginVar']['ListNum']).','.$this->Config['PluginVar']['ListNum'];

$FetchSql = 'SELECT W.title as Ttitle,S.* FROM '.DB::table($this->Tablese).' S LEFT JOIN '.DB::table($this->TableSeWord).' W on W.id = S.wid '.$Where .' order by topdateline > '.time().' desc,'.$Order.' desc,S.dateline desc '.$Limit;
$Results = $this->ListFormat(DB::fetch_all($FetchSql));
return $Results;
}






php mysql sql phpmyadmin






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 12 '18 at 13:34

























asked Nov 12 '18 at 12:33









Leung

12




12








  • 1




    ..i dont know how to do that in php code... Why doing this in both? You said mysql is working ... why php?
    – B001ᛦ
    Nov 12 '18 at 12:35












  • @B001ᛦ he wants to do it using PHP. the same thing he has done using MySQL. He wants to know where he can use the same query in his PHP code and replace the old query.
    – Sayed Mohd Ali
    Nov 12 '18 at 12:37












  • yes...i wants to do it using PHP. the same thing he has done using MySQL. I wants to know where he can use the same query in his PHP code and replace the old query
    – Leung
    Nov 12 '18 at 13:32
















  • 1




    ..i dont know how to do that in php code... Why doing this in both? You said mysql is working ... why php?
    – B001ᛦ
    Nov 12 '18 at 12:35












  • @B001ᛦ he wants to do it using PHP. the same thing he has done using MySQL. He wants to know where he can use the same query in his PHP code and replace the old query.
    – Sayed Mohd Ali
    Nov 12 '18 at 12:37












  • yes...i wants to do it using PHP. the same thing he has done using MySQL. I wants to know where he can use the same query in his PHP code and replace the old query
    – Leung
    Nov 12 '18 at 13:32










1




1




..i dont know how to do that in php code... Why doing this in both? You said mysql is working ... why php?
– B001ᛦ
Nov 12 '18 at 12:35






..i dont know how to do that in php code... Why doing this in both? You said mysql is working ... why php?
– B001ᛦ
Nov 12 '18 at 12:35














@B001ᛦ he wants to do it using PHP. the same thing he has done using MySQL. He wants to know where he can use the same query in his PHP code and replace the old query.
– Sayed Mohd Ali
Nov 12 '18 at 12:37






@B001ᛦ he wants to do it using PHP. the same thing he has done using MySQL. He wants to know where he can use the same query in his PHP code and replace the old query.
– Sayed Mohd Ali
Nov 12 '18 at 12:37














yes...i wants to do it using PHP. the same thing he has done using MySQL. I wants to know where he can use the same query in his PHP code and replace the old query
– Leung
Nov 12 '18 at 13:32






yes...i wants to do it using PHP. the same thing he has done using MySQL. I wants to know where he can use the same query in his PHP code and replace the old query
– Leung
Nov 12 '18 at 13:32














1 Answer
1






active

oldest

votes


















0














I think you should try and understand the code first before you modify it ... but anyway:



You would only need to append the condition to the where clause generated in the PHP code.
You could do that by adding THE LINE MARKED "THIS LINE IS NEW" after this line:



$Where = '';


And this is the relevant part of the code:



$Where = '';
$Order = 'S.updateline';
if($Get['type'] == 'New'){
$Where .= ' and S.wid in (1,2,3,4)'; //THIS LINE IS NEW
$Order = 'S.dateline';
}else .......


As you can see any redundant initial "and"s are replaced with "where" here:



$Where = preg_replace('/and/','where',$Where,1);


so this should work - assuming that $Get['type'] == 'New' means that this is a new post which I can only guess.






share|improve this answer























  • Thanks for your reply..after your edition, it is not work, it just show blank page.
    – Leung
    Nov 12 '18 at 15:21










  • Have you checked for syntax or SQL errors? The data type of wid is probably integer but I don't know. So you might want to change the code again. I have updated the NEW LINE above. You also might want to post the entire code AFTER making the change. I could take a look at that too.
    – rf1234
    Nov 12 '18 at 15:25












  • i tested add these works: and S.wid = 1 or S.wid = 2 or S.wid = 3
    – Leung
    Nov 12 '18 at 15:28












  • you have to be very careful with this because the WHERE clause has multiple ANDs that are generated. If you are not using brackets like in: and (S.wid = 1 or S.wid = 2 or S.wid = 3 or S.wid = 4) you might be in trouble.
    – rf1234
    Nov 12 '18 at 15:33










  • and change to these, it works well>> $Where .= ' and S.wid = 1 or S.wid = 2 or S.wid = 3 or S.wid = 4'; //THIS LINE IS NEW
    – Leung
    Nov 12 '18 at 15:36











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53262317%2fhow-can-i-do-this-sql-filter-results%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














I think you should try and understand the code first before you modify it ... but anyway:



You would only need to append the condition to the where clause generated in the PHP code.
You could do that by adding THE LINE MARKED "THIS LINE IS NEW" after this line:



$Where = '';


And this is the relevant part of the code:



$Where = '';
$Order = 'S.updateline';
if($Get['type'] == 'New'){
$Where .= ' and S.wid in (1,2,3,4)'; //THIS LINE IS NEW
$Order = 'S.dateline';
}else .......


As you can see any redundant initial "and"s are replaced with "where" here:



$Where = preg_replace('/and/','where',$Where,1);


so this should work - assuming that $Get['type'] == 'New' means that this is a new post which I can only guess.






share|improve this answer























  • Thanks for your reply..after your edition, it is not work, it just show blank page.
    – Leung
    Nov 12 '18 at 15:21










  • Have you checked for syntax or SQL errors? The data type of wid is probably integer but I don't know. So you might want to change the code again. I have updated the NEW LINE above. You also might want to post the entire code AFTER making the change. I could take a look at that too.
    – rf1234
    Nov 12 '18 at 15:25












  • i tested add these works: and S.wid = 1 or S.wid = 2 or S.wid = 3
    – Leung
    Nov 12 '18 at 15:28












  • you have to be very careful with this because the WHERE clause has multiple ANDs that are generated. If you are not using brackets like in: and (S.wid = 1 or S.wid = 2 or S.wid = 3 or S.wid = 4) you might be in trouble.
    – rf1234
    Nov 12 '18 at 15:33










  • and change to these, it works well>> $Where .= ' and S.wid = 1 or S.wid = 2 or S.wid = 3 or S.wid = 4'; //THIS LINE IS NEW
    – Leung
    Nov 12 '18 at 15:36
















0














I think you should try and understand the code first before you modify it ... but anyway:



You would only need to append the condition to the where clause generated in the PHP code.
You could do that by adding THE LINE MARKED "THIS LINE IS NEW" after this line:



$Where = '';


And this is the relevant part of the code:



$Where = '';
$Order = 'S.updateline';
if($Get['type'] == 'New'){
$Where .= ' and S.wid in (1,2,3,4)'; //THIS LINE IS NEW
$Order = 'S.dateline';
}else .......


As you can see any redundant initial "and"s are replaced with "where" here:



$Where = preg_replace('/and/','where',$Where,1);


so this should work - assuming that $Get['type'] == 'New' means that this is a new post which I can only guess.






share|improve this answer























  • Thanks for your reply..after your edition, it is not work, it just show blank page.
    – Leung
    Nov 12 '18 at 15:21










  • Have you checked for syntax or SQL errors? The data type of wid is probably integer but I don't know. So you might want to change the code again. I have updated the NEW LINE above. You also might want to post the entire code AFTER making the change. I could take a look at that too.
    – rf1234
    Nov 12 '18 at 15:25












  • i tested add these works: and S.wid = 1 or S.wid = 2 or S.wid = 3
    – Leung
    Nov 12 '18 at 15:28












  • you have to be very careful with this because the WHERE clause has multiple ANDs that are generated. If you are not using brackets like in: and (S.wid = 1 or S.wid = 2 or S.wid = 3 or S.wid = 4) you might be in trouble.
    – rf1234
    Nov 12 '18 at 15:33










  • and change to these, it works well>> $Where .= ' and S.wid = 1 or S.wid = 2 or S.wid = 3 or S.wid = 4'; //THIS LINE IS NEW
    – Leung
    Nov 12 '18 at 15:36














0












0








0






I think you should try and understand the code first before you modify it ... but anyway:



You would only need to append the condition to the where clause generated in the PHP code.
You could do that by adding THE LINE MARKED "THIS LINE IS NEW" after this line:



$Where = '';


And this is the relevant part of the code:



$Where = '';
$Order = 'S.updateline';
if($Get['type'] == 'New'){
$Where .= ' and S.wid in (1,2,3,4)'; //THIS LINE IS NEW
$Order = 'S.dateline';
}else .......


As you can see any redundant initial "and"s are replaced with "where" here:



$Where = preg_replace('/and/','where',$Where,1);


so this should work - assuming that $Get['type'] == 'New' means that this is a new post which I can only guess.






share|improve this answer














I think you should try and understand the code first before you modify it ... but anyway:



You would only need to append the condition to the where clause generated in the PHP code.
You could do that by adding THE LINE MARKED "THIS LINE IS NEW" after this line:



$Where = '';


And this is the relevant part of the code:



$Where = '';
$Order = 'S.updateline';
if($Get['type'] == 'New'){
$Where .= ' and S.wid in (1,2,3,4)'; //THIS LINE IS NEW
$Order = 'S.dateline';
}else .......


As you can see any redundant initial "and"s are replaced with "where" here:



$Where = preg_replace('/and/','where',$Where,1);


so this should work - assuming that $Get['type'] == 'New' means that this is a new post which I can only guess.







share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 12 '18 at 15:25

























answered Nov 12 '18 at 14:49









rf1234

40257




40257












  • Thanks for your reply..after your edition, it is not work, it just show blank page.
    – Leung
    Nov 12 '18 at 15:21










  • Have you checked for syntax or SQL errors? The data type of wid is probably integer but I don't know. So you might want to change the code again. I have updated the NEW LINE above. You also might want to post the entire code AFTER making the change. I could take a look at that too.
    – rf1234
    Nov 12 '18 at 15:25












  • i tested add these works: and S.wid = 1 or S.wid = 2 or S.wid = 3
    – Leung
    Nov 12 '18 at 15:28












  • you have to be very careful with this because the WHERE clause has multiple ANDs that are generated. If you are not using brackets like in: and (S.wid = 1 or S.wid = 2 or S.wid = 3 or S.wid = 4) you might be in trouble.
    – rf1234
    Nov 12 '18 at 15:33










  • and change to these, it works well>> $Where .= ' and S.wid = 1 or S.wid = 2 or S.wid = 3 or S.wid = 4'; //THIS LINE IS NEW
    – Leung
    Nov 12 '18 at 15:36


















  • Thanks for your reply..after your edition, it is not work, it just show blank page.
    – Leung
    Nov 12 '18 at 15:21










  • Have you checked for syntax or SQL errors? The data type of wid is probably integer but I don't know. So you might want to change the code again. I have updated the NEW LINE above. You also might want to post the entire code AFTER making the change. I could take a look at that too.
    – rf1234
    Nov 12 '18 at 15:25












  • i tested add these works: and S.wid = 1 or S.wid = 2 or S.wid = 3
    – Leung
    Nov 12 '18 at 15:28












  • you have to be very careful with this because the WHERE clause has multiple ANDs that are generated. If you are not using brackets like in: and (S.wid = 1 or S.wid = 2 or S.wid = 3 or S.wid = 4) you might be in trouble.
    – rf1234
    Nov 12 '18 at 15:33










  • and change to these, it works well>> $Where .= ' and S.wid = 1 or S.wid = 2 or S.wid = 3 or S.wid = 4'; //THIS LINE IS NEW
    – Leung
    Nov 12 '18 at 15:36
















Thanks for your reply..after your edition, it is not work, it just show blank page.
– Leung
Nov 12 '18 at 15:21




Thanks for your reply..after your edition, it is not work, it just show blank page.
– Leung
Nov 12 '18 at 15:21












Have you checked for syntax or SQL errors? The data type of wid is probably integer but I don't know. So you might want to change the code again. I have updated the NEW LINE above. You also might want to post the entire code AFTER making the change. I could take a look at that too.
– rf1234
Nov 12 '18 at 15:25






Have you checked for syntax or SQL errors? The data type of wid is probably integer but I don't know. So you might want to change the code again. I have updated the NEW LINE above. You also might want to post the entire code AFTER making the change. I could take a look at that too.
– rf1234
Nov 12 '18 at 15:25














i tested add these works: and S.wid = 1 or S.wid = 2 or S.wid = 3
– Leung
Nov 12 '18 at 15:28






i tested add these works: and S.wid = 1 or S.wid = 2 or S.wid = 3
– Leung
Nov 12 '18 at 15:28














you have to be very careful with this because the WHERE clause has multiple ANDs that are generated. If you are not using brackets like in: and (S.wid = 1 or S.wid = 2 or S.wid = 3 or S.wid = 4) you might be in trouble.
– rf1234
Nov 12 '18 at 15:33




you have to be very careful with this because the WHERE clause has multiple ANDs that are generated. If you are not using brackets like in: and (S.wid = 1 or S.wid = 2 or S.wid = 3 or S.wid = 4) you might be in trouble.
– rf1234
Nov 12 '18 at 15:33












and change to these, it works well>> $Where .= ' and S.wid = 1 or S.wid = 2 or S.wid = 3 or S.wid = 4'; //THIS LINE IS NEW
– Leung
Nov 12 '18 at 15:36




and change to these, it works well>> $Where .= ' and S.wid = 1 or S.wid = 2 or S.wid = 3 or S.wid = 4'; //THIS LINE IS NEW
– Leung
Nov 12 '18 at 15:36


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53262317%2fhow-can-i-do-this-sql-filter-results%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

The Sandy Post

Danny Elfman

Pages that link to "Head v. Amoskeag Manufacturing Co."