I have the following code which display different things, that's why I'm using many filters in the query. The problem is that it displays the same thing, no matter the query from the switch.
If I do something like
SELECT * FROM wp_posts WHERE ID='100'
as example, it will display
SELECT * FROM wp_posts ...
Also, I've added where post_type='post'
and it display all kind of things that he found in the database, like pictures, contact form, etc.
if(isset($_GET["submit"])){
$nume_searchq=$_GET["nume_doc"];
$spec_searchq=$_GET["specializare_doc"];
$instit_searchq=$_GET["spital_doc"];
switch($_GET['filter1']){
case "ALL":
$querystr = "SELECT * FROM `wp_posts` WHERE post_type='post' OR LOWER(post_title) LIKE '%$nume_searchq%' OR LOWER(post_content) LIKE '%$spec_searchq%' OR LOWER(post_content) LIKE '%$instit_searchq%' LIMIT $limit";
break;
case "AB":
$querystr = "SELECT * FROM `wp_posts` WHERE post_content LIKE '%Alba%' AND post_type='post' OR LOWER(post_title) LIKE '%$nume_searchq%' OR LOWER(post_content) LIKE '%$spec_searchq%' OR LOWER(post_content) LIKE '%$instit_searchq%' LIMIT $limit ";
break;
case "AG":
$querystr = "SELECT * FROM `wp_posts` WHERE post_content LIKE '%Arges%' AND post_type='post' OR LOWER(post_title) LIKE '%$nume_searchq%' OR LOWER(post_content) LIKE '%$spec_searchq%' OR LOWER(post_content) LIKE '%$instit_searchq%' LIMIT $limit ";
}
$pageposts = $wpdb->get_results($querystr, OBJECT);?>
<?php if ($pageposts): ?>
<?php foreach ($pageposts as $post): ?>
<?php setup_postdata($post); ?>
<div class="post" id="post-<?php the_ID(); ?>">
<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>">
<?php the_title(); ?></a></h2>
<?php //display_rating_result(); ?>
<div class="entry">
<?php the_content('Read the rest of this entry »'); ?>
</div>
<?php edit_post_link('Edit', '', ' | '); ?>
<?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?></p>
</div>
<hr>
<?php endforeach; ?>
<?php else : ?>
<h2 class="center">Not Found</h2>
<?php endif; ?>
Where might be the problem in these queries?