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

Painful problem for ya :)

I have which has dynamic checkboxes named "holdtalent" which have the
value from a recordset "talent_id". I have a query to a recordset
getting the checkboxs state. If "Y" it is ticked, if "N" it is not
ticked.

This works fine and the data displays as does the checkbox state.

If I untick a checkbox, I want to update the database with "N". an
unticked checkbox doesnt send anything through $_POST so how do I get
the change in there?

I thought maybe.. I have recordset with the talent_id and the state
already there. If I refine that recordset to only give me the checked
values "Y" into a new array, then when the form is posted back with no
corresponding value but was "Y" in the recordset, then it must have
been unchecked, so update that row with "N" as the state.

But whats teh code to do eeet?

Also, if I have a recordset I'm paging through, with checkboxes, and I
check some on one page, then page through again and select some more,
how do I get those pre-selected values? Each time I page through it
doesnt remember the previous pages values.

I thought maybe dynamically setting the state of the checkbox with a
session variable. Then each time a "Next Page" link is clicked, it
submits the form recording the session state for that pages buttons.
But If I have a lot of data, I'll have a tonne of session variables.
And then how would I differentiate between when a form is submitted by
a button or a "Next Page" link?

I really dont want to use javascript to write the cookies each time a
checkbox is clicked as it might be incompatible with browser setups.

Another way would be perhaps parseing it into the querystring..
".php?cb1=y&cb4=n" etc but I have a string limit. There won't be THAT
many records, but I want the perfect solution.

Heeeeeeeeeeeelp :)
Jul 17 '05 #1
3 1591
RelaxoRy wrote:
If I untick a checkbox, I want to update the database with "N". an
unticked checkbox doesnt send anything through $_POST so how do I get
the change in there?


The following would be the easiest:

if (!isset($_POST['holdtalent'])) $_POST['holdtalent'] = 'N';

A nicer approach, however, is to set a default for the table field (alter
table sometable change field field varchar(3) default 'N'). Then you would
only include this field in your query when $_POST['holdtalent'] has been
set...
JW

Jul 17 '05 #2
RelaxoRy wrote:
I have which has dynamic checkboxes named "holdtalent" which have the
value from a recordset "talent_id". I have a query to a recordset
getting the checkboxs state. If "Y" it is ticked, if "N" it is not
ticked.

This works fine and the data displays as does the checkbox state.

If I untick a checkbox, I want to update the database with "N". an
unticked checkbox doesnt send anything through $_POST so how do I get
the change in there?


What I would probably do is just include a hidden field with ALL the
ID's together, separated by a space. Then you can take that field and
for every checkbox that is returned, remove that ID from the field's
list. After you have processed the checkboxes, the field would then
containe a list of those checkboxes that were displayed, but not checked
by the user. Pretty simple and effective.
Jul 17 '05 #3
"RelaxoRy" <re******@postmaster.co.uk> wrote in message
news:3b**************************@posting.google.c om...
I have which has dynamic checkboxes named "holdtalent" which have the
value from a recordset "talent_id". I have a query to a recordset
getting the checkboxs state. If "Y" it is ticked, if "N" it is not
ticked.

This works fine and the data displays as does the checkbox state.

If I untick a checkbox, I want to update the database with "N". an
unticked checkbox doesnt send anything through $_POST so how do I get
the change in there?


You need to build a list of records that are to updated with Y, and then use
that list in a positive and negative fashion.

$aVar = array(
1 => 1, 3 => 1, 5 => 1, 6 => 1);

$reclist = '';
$sep = '';
foreach($aVar as $k => $v)
{
$reclist .= sprintf(" %s id = '%s'",
$sep, $k);
$sep = 'OR';
}

$sql = sprintf("UPDATE tablename SET fieldname='N' WHERE !(%s)" ,
$reclist);
echo $sql . "\n";
$sql = sprintf("UPDATE tablename SET fieldname='Y' WHERE (%s)",
$reclist);
echo $sql . "\n";

Jul 17 '05 #4

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

Similar topics

12
by: vincent_delft | last post by:
I'm looking for a Web Tool kit to build web pages with the following criteria (in priority order) : - easy to use, develop (reuseability of code, ...) - flexible (ideally should run with Python...
145
by: David MacQuigg | last post by:
Playing with Prothon today, I am fascinated by the idea of eliminating classes in Python. I'm trying to figure out what fundamental benefit there is to having classes. Is all this complexity...
5
by: Humpty Dumpty | last post by:
Hello, I've been using python for about 3 months now. Prior to that I did C++ for over 5 years. I'm wondering if my debugging techniques are too C++ oriented. E.g., it took me about 9 hrs of...
16
by: Luis P. Mendes | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi, I only know a little bit of xml and I'm trying to parse a xml document in order to save its elements in a file (dictionaries inside a list)....
4
by: jason | last post by:
Hello. Newbie on SQL and suffering through this. I have two tables created as such: drop table table1; go drop table table2; go
1
by: Wilson | last post by:
Hi I am sorry for posting the following dumb question but I have a problem and need help. I am a newbie in this area.. I am trying to translate an AD user name into an FDQN and then bind to the...
22
by: Matthew Louden | last post by:
I want to know why C# doesnt support multiple inheritance? But why we can inherit multiple interfaces instead? I know this is the rule, but I dont understand why. Can anyone give me some concrete...
1
by: Corey2004 | last post by:
I am importing a visual 6 C++ dll into C#. The methods in the dll take a CList type and I was wondering what type in C# can I use that correctly matches the CList type. Is the ArrayList type in C#...
2
by: robert112 | last post by:
my ie7 throws a 'page cannot be found' error when I leave my asp.net application no a debugging line. it gives me about 30 seconds worth of debug time before it throws that message and then when i...
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...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
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...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
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 =...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

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.