473,238 Members | 1,819 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,238 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 4437
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: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...

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.