I did a Web search, and a deja.com search on this...and I'm finding
how to make checkboxes act like radiobuttons, and other interesting
behaviors, but nothing that quite answers my question. If someone has
a link or thread they know about, even just that would be great!
What I have is a page that generates a list of items from a
database...a list of rows.
I'm having each row in the WHILE array create a checkbox, so that
someone can put checks in any row they want to delete on submitting
the form.
Now, how do I set up where it collects which checkboxes were selected?
I'm sure if I can get that far, I can figure out an EACH method of
then deleting each id from the table.
Here's what I'm doing so far with the checkboxes:
while ($row = mysql_fetch_arr ay($result)) {
echo "<tr ".$bgcolour.">< td><input name=\"del\"
type=\"checkbox \" value=\"$iid\"> </td><td>" . $quantity . "</td><td>"
.. $typename . "</td><td>" . $typesize . "</td><td>$" . $amount .
"</td><td></td><td></td><td>$".round (($amount*$taxm ult),2)."</td></tr>";
The $iid is the table.id mentioned in the SELECT statment before this.
So that each checkbox, when checked, will have a value of that row's
ID.
Any suggestions, even just a one-word name of the method I should look
into, would be much appreciated!
Thanks!
Liam 5 2213
I noticed that Message-ID:
<3a************ **************@ posting.google. com> from LRW contained the
following: while ($row = mysql_fetch_arr ay($result)) { echo "<tr ".$bgcolour.">< td><input name=\"del\" type=\"checkbo x\" value=\"$iid\"> </td><td>" . $quantity . "</td><td>" . $typename . "</td><td>" . $typesize . "</td><td>$" . $amount . "</td><td></td><td></td><td>$".round (($amount*$taxm ult),2)."</td></tr>";
The $iid is the table.id mentioned in the SELECT statment before this. So that each checkbox, when checked, will have a value of that row's ID.
The way I did this as to sequentially name the check boxes e.g.
$i=0;
while ($row = mysql_fetch_arr ay($result)) {
echo "<tr ".$bgcolour.">< td><input name=\"del$i\"
type=\"checkbox \" value=\"$iid\"> </td><td>" . $quantity . "</td><td>"
.. $typename . "</td><td>" . $typesize . "</td><td>$" . $amount .
"</td><td></td><td></td><td>$".round (($amount*$taxm ult),2)."</td></tr>";
$i++;
}
You know how many check boxes you have printed. When the form is
returned, do a loop to see which boxes are ticked.
for($i=0;$i<$nu mber_of_boxes; $i++){
if(isset($_POST["del$i"])){
//do delete stuff
}
}
--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
"LRW" <de**@celticbea r.com> wrote in message
news:3a******** *************** ***@posting.goo gle.com... I did a Web search, and a deja.com search on this...and I'm finding how to make checkboxes act like radiobuttons, and other interesting behaviors, but nothing that quite answers my question. If someone has a link or thread they know about, even just that would be great!
What I have is a page that generates a list of items from a database...a list of rows. I'm having each row in the WHILE array create a checkbox, so that someone can put checks in any row they want to delete on submitting the form.
Now, how do I set up where it collects which checkboxes were selected? I'm sure if I can get that far, I can figure out an EACH method of then deleting each id from the table.
Here's what I'm doing so far with the checkboxes: while ($row = mysql_fetch_arr ay($result)) { echo "<tr ".$bgcolour.">< td><input name=\"del\" type=\"checkbox \" value=\"$iid\"> </td><td>" . $quantity . "</td><td>" . $typename . "</td><td>" . $typesize . "</td><td>$" . $amount . "</td><td></td><td></td><td>$".round (($amount*$taxm ult),2)."</td></tr>";
The $iid is the table.id mentioned in the SELECT statment before this. So that each checkbox, when checked, will have a value of that row's ID.
Any suggestions, even just a one-word name of the method I should look into, would be much appreciated!
Thanks! Liam
I've always done it this way:
while ($row = mysql_fetch_arr ay($result)) {
print "<tr><td><i nput type='checkbox' name='del[]' value='del'><in put
type='hidden'
name='values[]'value='$id'></td><td>$quantit y</td><td>$typenam e</td><td>$typ
esize</td><td>$."$amou nt".</td><td></td><td></td><td>$".round (($amount*$taxm
ult),2)."</td></tr>";
}
then when you're processing the data do something like....
for ($i = 0; $i < count($values); $i++) {
if($del[$i] = 'del') {
deleteRecord($i );
}
}
Regards,
Ian.
"Ian Taylor" <mx*@ocset.reve rse.previous.wo rd.net> wrote in message news:<40******* *************** *@news.dial.pip ex.com>...
Actually, what I ended up figuring out was a lot easier than those:
<input name="del[]" type="checkbox" value="$iid">
Then on the PHP:
if ($del) {
foreach ($del as $v) {
$sqldel = "delete from orderscart where id = '".$v."' and
ordernum = '".$ordernum."' ";
$result = @mysql_query($s qldel, $dbconn);
}
}
Works great!
Thanks for the tips to get me ther...
Liam
I noticed that Message-ID:
<3a************ **************@ posting.google. com> from LRW contained the
following: if ($del) { foreach ($del as $v) { $sqldel = "delete from orderscart where id = '".$v."' and ordernum = '".$ordernum."' "; $result = @mysql_query($s qldel, $dbconn); } }
Works great!
Yeah, the only thing I don't like about that is that it works too well.
I like to have an intermediate screen asking me if I'm sure I want to
delete these records.
--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
"Geoff Berrow" <bl******@ckdog .co.uk> wrote in message
news:kr******** *************** *********@4ax.c om... I noticed that Message-ID: <3a************ **************@ posting.google. com> from LRW contained the following:
if ($del) { foreach ($del as $v) { $sqldel = "delete from orderscart where id = '".$v."' and ordernum = '".$ordernum."' "; $result = @mysql_query($s qldel, $dbconn); } }
Works great!
Yeah, the only thing I don't like about that is that it works too well. I like to have an intermediate screen asking me if I'm sure I want to delete these records.
Oh, good point. I'll take a closer look at the other methods; see if I can
suss them out.
Thanks,
Liam This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Nik Coughin |
last post by:
I am having a problem with checkboxes...
I have a number of blocks like this on my form:
<input type="text" name="name" value="a name">
<input type="text" name="ddi" value="1234">
<input type="checkbox" name="delete">
If I then submit the form, the array $delete is the only one which isn't
indexed by its order on the form.
|
by: Nath |
last post by:
Please help!?
I am new to writing html, javascript, pretty new to MySQL but quite
proficient at writing Perl and i'm a quick learner.
I am building a database driven website and i am a little stuck:
I have page of results obtained from a MySQL query presented as a table (the
first column having checkboxes for each of the rows in the table, and all
having the name "seqs"). I have set up a javascript (connected to a "toggle
all" checkbox)...
|
by: Oleg Konovalov |
last post by:
Hi,
I am trying to pass a bunch of checked checkboxes (Javascript array)
from page1 to the Java action class on subsequent web page (page2).
(on page 1 I have a bunch of DB rows with a checkbox,
need to iterate through pages page2 - e.g. allow user to update the fields
there)
On page1 I have a bunch of checkboxes with the same name v1
but different values (= DB rowId).
|
by: aparth |
last post by:
Hi, I'm having a problem simply putting the values of selected checkboxes into an array using javascript.
The list of checkboxes is dynamically created so I need to count number of checkboxes in order to cycle through them. Also the value of these checkboxes is not 1,2,3,4,5. They are non-sequential id numbers.
function update(chkbox_name)
{
var ids = new Array();
var count = 0;
for(var i=0; i < chkbox_name.length; i++)
{
|
by: dude |
last post by:
i'll try to be short ... i have this in html :
<select name="OS" size="5">
<option value="0" selected>Please select one or more...</option>
<option value="1">Windows</option>
<option value="2">Mac OS X</option>
<option value="3">Linux</option>
</select>
and i want to echo the values from this simple list (OS), i mean array
| |
by: T. Wintershoven |
last post by:
Hello all,
I have a form with some checkboxes.
The names of these checkboxes come from an array.
When i click the submit button the resultcode doesn't recognize the names
when i want to check wether or not some checkboxes are ticked.
Assume that i tick checkboxes 100, 150 and 200
Below is some code i've used.(between the ****** lines)
|
by: hugonot |
last post by:
I have got a problem with checkboxes array and the form.
I have the results from table (MySQL) and checkbox (form) near the results.
I use:
echo "<input type=checkbox name=box value=".$.">";
for checkbox i.e. I create array of checkbox.
How can I remember the state of checkboxes in array and pass it by GET?
I know how to do it with a single checkbox already selected inside the code:
$next = " <a...
|
by: TechnoAtif |
last post by:
Hi ALL
I have entered some array values using checkboxes into mysql database through a form. Next iam creating a searchpage where all those cateogories inserted through checkboxes has to be retrieved using list/menu box.
When i check only a single checkbox to insert the checked category ,selecting that category through list box gives out the entire data of the user corresponding to that category.
However when i check multiple checkboxes and...
|
by: mab464 |
last post by:
I have this code on my WAMP server running on my XP machine
if ( isset( $_POST ) )
{
for($i=0; $i<count($_POST);$i++)
{
if ($ans != NULL )
$ans .= ", " . $_POST ; // Not the first
element so append a comma
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |