473,394 Members | 1,841 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

filter results from a check box

hello.

i have a checkbox like this
Expand|Select|Wrap|Line Numbers
  1. <input name="request" type="checkbox" id="request" value="1" checked="checked" />
  2.  
and i send the value 1 or 0 into my sql database.

how can i filter the results depending if the box is 0 or 1

i got this code but it doesn't return results when $request='0'
Expand|Select|Wrap|Line Numbers
  1. if($type == 'like' && $request='1' && $request='0')
  2.       {
  3.         $sql = 'SELECT * FROM topic WHERE (test LIKE '."'%$search%') AND request='1'";
  4.       }
  5.     elseif($type == 'like' && $request='0')
  6.       {
  7.         $sql = 'SELECT * FROM topic WHERE (test LIKE '."'%$search%') AND request='0'";
  8.       }
  9.  
thanks
Sep 16 '10 #1
6 3003
zorgi
431 Expert 256MB
Expand|Select|Wrap|Line Numbers
  1. if($type == 'like' && $request='1' && $request='0')
  2.  
You are assigning value to your $request variable ... Check out Comparison Operators
Sep 16 '10 #2
this
Expand|Select|Wrap|Line Numbers
  1. if($type == 'like' && $request =='1' && $request =='0')
gives a syntax error
Sep 16 '10 #3
zorgi
431 Expert 256MB
@patrioticcow
I don't see syntax issues but I do see huge logic issue as your condition will NEVER be true.

Expand|Select|Wrap|Line Numbers
  1. if($request =='1' && $request =='0')
  2.  
Read that as IF $request IS 1 AND IF $request IS 0 ... at the same time!? Impossible ... it will never happen
Sep 16 '10 #4
oh. i see.
but even if i leave it like this it still wont work

Expand|Select|Wrap|Line Numbers
  1.     if($type == 'like' && $request='1' && $request='0')
  2.           {
  3.             $sql = 'SELECT * FROM topic WHERE (test LIKE '."'%$search%') AND request='1'";
  4.           }
  5.         elseif($type == 'like' && $request='0')
  6.           {
  7.             $sql = 'SELECT * FROM topic WHERE (test LIKE '."'%$search%') AND request='0'";
  8.           }
  9.  
i mean it only shows the results that have 1 in the database
Sep 16 '10 #5
zorgi
431 Expert 256MB
Now you are assigning values again.... Maybe this helps
Sep 16 '10 #6
$request='1' is a checkbox that has values 1 or 0.

so what i am saying id that if the checkbox is checked display the results from SEARCH and REQUEST.

Expand|Select|Wrap|Line Numbers
  1.   if($type == 'like' && $request='1')
  2.            {
  3.              $sql = 'SELECT * FROM topic WHERE (test LIKE '."'%$search%') AND request='1'";
  4.            }
  5.          elseif($type == 'like' && $request='0')
  6. #           {
  7.              $sql = 'SELECT * FROM topic WHERE (test LIKE '."'%$search%') AND request='0'";
  8.            }
  9.  
or u think i need to use status="'.$active.'"'
Sep 16 '10 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Bert | last post by:
Sorry for the unclear subject line. I've got to write a download script for and existing file manager (we are working on a complete redesign for this file manager, but the functionality of...
1
by: soupaman | last post by:
Im trying to output some filtered xml using the xmlTextReader I know the code and commenting needs cleaned up and eventually plan to add the values to a dataset. currently what this is doing is...
1
by: Mike C | last post by:
i have a 2 column datagrid (account_id, account). the second is a hyperlink column with a URL Column account_id and a URL Format String EnterTargets.aspx?id={0}. It looks like it's passing the...
0
by: inetquestion | last post by:
Can someone point me in the right direction regarding xml/xslt? I have the following xml file with corresponding xslt and would like to add some aditional functionality where a viewer can select...
0
by: Faybert | last post by:
Hello, and Thanks in advance for any light you might shed on my troubles. I'm trying to setup a series of checkboxes, or a checkboxlist to control the results that are shown on a gridview...
6
by: supasnail | last post by:
I've been going round in circles here trying to get this to work and my ignorance of ASP is now showing me up. I want to construct a query string to allow me to filter entries to be displayed on...
0
by: joebob8000 | last post by:
This seems like a simple task, but my 6 year old roots in classic ASP must be causing me trouble with my current problem. I am looking to provide a search for users in which they can select...
7
by: Scotter | last post by:
Ok, I know I've seen how to do this somewhere but I can't seem to find it again... My setup is I have a form that has 5 text boxes and 1 check box. "txtFirstName", "txtLastName", "txtDelDate",...
34
gcoaster
by: gcoaster | last post by:
Hello Everyone! I have a question regarding "cascading combobox(s) list(s)" I would like: ComboBox 2 to show results from ComboBox 1's selection, then ComboBox 4 to show results from...
2
by: franc sutherland | last post by:
Hello, I am using Access 2003. I have a query which shows a list of club meetings sorted by date. This query is displayed in continuous forms, in a subform. I would like to select a month on...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.