473,385 Members | 1,343 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,385 software developers and data experts.

Result of checkbox selection into an SQL request

Hi,

I would transfer the result of a checkbox selection into an SQL request.

Could you help me ?

Many thanks in advance

Nicolas
Sep 13 '05 #1
4 4446
Nicolas Rubin wrote:
I would transfer the result of a checkbox selection into an SQL request.
Could you help me ?


Checkboxes are a bit of a problem: they will only be submitted if
checked. However, the positive thing is that they take the "value"
argument, so basically you can make then anything.

Suggestion: use HTML_QuickForm, and then use the advcheckbox element,
which removes the need to check if the variable has been set or not, you
only need to worry about processing the value. (=> pear.php.net)

/Marcin
Sep 13 '05 #2
<?php
$sql="select id, name from table";
if (isset($_POST['fieldname'])){
$sql.=" where field='blue'";
}else{
$sql.=" where field='red'";
}
?>
Nicolas Rubin wrote:
Hi,

I would transfer the result of a checkbox selection into an SQL request.

Could you help me ?

Many thanks in advance

Nicolas

Sep 13 '05 #3
Nicolas Rubin wrote:
Hi,

I would transfer the result of a checkbox selection into an SQL request.

Could you help me ?

Many thanks in advance

Nicolas


Hi

If you expect a checkbox named 'clientwantsspam', try this in the receiving
script:

$clientwantsspam = "N";
if (isset($_POST["clientwantsspam"])){
$clientwantsspam = "Y";
}

or any other variation that suits your needs.

eg: if you want the VALUE of the checkbox:
$clientwantsspam = "notavailable";
if (isset($_POST["clientwantsspam"])){
$clientwantsspam = $_POST["clientwantsspam"];
}
The point/problem is that the checkbox is only send when checked, so your
receiving script must test if it exists.

Of course you can also use shorthandnotation:
$clientwantsspam = ((isset($_POST["clientwantsspam"]) ?
$_POST["clientwantsspam"]: "NotAvailable");

which probably wrapped in your newsreader. ;-)

Good luck.

Regards,
Erwin Moller
Sep 13 '05 #4
In article <43**********@news.bluewin.ch>, Nicolas Rubin <nr*@e-systems.ch>
wrote:
Hi,

I would transfer the result of a checkbox selection into an SQL request.

Could you help me ?


Yes, but not until you actually give us a bit more information about what you
want to do.
--
Sandman[.net]
Sep 13 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Jack | last post by:
Hi, I have a form when loaded, retrieves record from an access table. Among other fields there is a check box called FinalUpdate. This is tied to a field in Access of type Yes/No. The form...
3
by: Jack | last post by:
<i><input type="checkbox" name="chk_Complete" value="TRUE" <%Response.Write l_IsChecked%>"<%if cbool(l_IsChecked) then Response.Write " checked" Else Response.Write " unchecked"%>> The above...
2
by: Andre Ranieri | last post by:
Hi folks, I have a datagrid which contains a template item checkbox column. I've included a checkbox as a HeaderTemplate item which fires a server-side function to check or uncheck all the...
1
by: mercercreek | last post by:
This one should be easy. Hope someone has a clue. Simple Scenario: Gridview with mulitple rows, each row with a checkbox. The user checks boxes of her choice. Clicks a button on the form (not in...
0
by: New2ASP | last post by:
Thanks everyone in advance for your help. I am fairly new to web development but an experienced window-based developer. Here's the structure of my Gridview Column 1 : Checkbox with SelectAll...
0
by: cyberdawg999 | last post by:
Greetings all in ASP land I have overcome one obstacle that took me 2 weeks to overcome and I did it!!!!! I am so elated!! thank you to all who invested their time and energy towards helping me...
3
by: uremog | last post by:
I have a set of of check boxes. onClick, the checkboxes call check_radio and recup_checkbox. the referenced radios function as group selectors. check_radio just unchecks the radios if someone...
11
by: =?Utf-8?B?UGFyYWcgR2Fpa3dhZA==?= | last post by:
Hi All, I have a large recordset to be displayed on a ASP 3.0 page. I am using recordset paging for this. For the next and previous link i am passing href as <a href=<Page URl>?page=<%=...
4
by: Charlotte | last post by:
Hi, I have a problem with a ASP-script, can somewone help me ? here is what I've got: mypage.asp : .... code ... <%
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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?

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.