473,404 Members | 2,114 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,404 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 1599
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.