Re: [PHP-DB] checkboxes

2005-01-21 Thread Craig Hoffman
Great - Thanks.  That worked fine.  Now the next question. ;)
How can I update MySQL with the array values I just generated?
Basically if you checked two checkboxes, that represents two rows in 
MySQL.  How can I update those two rows in the DB?

code snippet
Array: Array ( [0] => Done (completed)  [1] => 1 (user_id)  [2] => 
Northeast Ridge (route_name) [3] => 2(id) [4] => Done [5] => 1 [6] => 
Kahiltna Spire [7] => 4 )

$com = array("$_POST[completed]", "$_POST[route_name]", "$_POST[id]", 
"$_POST[user_id]");
 print_r ($completed);
 //foreach ($com as $key => $values) {
include "include/db.php";
  $query = "UPDATE ticklist SET completed = '$completed' WHERE 
route_name = '$route_name' AND id = '$id' AND user_id = '$user_id'";
   echo $query;
$msg = "Could not insert 
record";
$result = mysql_query($query,$db) or 
die(mysql_error($msg));

Thanks - CH
On Jan 21, 2005, at 3:47 PM, Hutchins, Richard wrote:
You can't just echo out an array. You have to either use print_r() or
iterate over it with a while or for...next loop. But if you just want 
to see
what's in the array, print_r() it.

As to why it doesn't bring over the other checkboxes...
If you have (pseudocode)


 Checkbox 1
 Checkbox 2
 Checkbox 3



And you check the first two checkboxes, then the resulting array will 
be
(pseudocode again):
completed(value1,value2)

And from there, you just access the array contents as you would with 
any
other multidimensional array.

If you don't check anything on the page, then the array will be empty 
and, I
think, won't even be sent in the $_POST array. I'm sure somebody will
correct me there if my memory has failed me.

-----Original Message-----
From: Craig Hoffman [mailto:[EMAIL PROTECTED]
Sent: Friday, January 21, 2005 4:32 PM
To: php-db@lists.php.net
Cc: Richard Hutchins
Subject: Re: [PHP-DB] checkboxes
I've tried that and it still doesn't bring over the other checkboxes
that have been checked.  Plus when I echo it out I get
Array  instead of the variable name.
On Jan 21, 2005, at 3:14 PM, Hutchins, Richard wrote:
Probably all you need to do is name your checkboxes as an array 
thusly:

name="completed[]"
Then you can access the array on your update page and do whatever you
wish
with it.
Hope this helps.
Rich
-Original Message-
From: Craig Hoffman [mailto:[EMAIL PROTECTED]
Sent: Friday, January 21, 2005 4:03 PM
To: php-db@lists.php.net
Subject: [PHP-DB] checkboxes
I have a form that display's a checkbox if the value is NULL. The form
is in a do... while loop, so the user may check multiple checkboxes.
I am trying to pass the variable of each checkboxes to an update
statement in MySQL.  THe problem is I am only getting one of the
checkboxes, even if all of them are checked.  Here is my code block,
any help would be great.  - Craig
//From form page

  

//MySQL Update Page
$email = $_POST['email'] == $route;
$completed = $_POST["completed"] == $route;
 $route_name = trim($_POST["route_name"]) == $route;
$user_id = $_POST['user_id'] == $route;
$id = $_POST['id'] == $route;
$route = array(id => "$_POST[id]", completed => "$_POST[completed]",
route_name => "$_POST[route_name]", user_id => "$_POST[user_id]");
 foreach ($route as $key => $values) {
echo("");
echo $values;
   //MySQL Update statement will go here.
}
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP-DB] checkboxes

2005-01-21 Thread Hutchins, Richard
You can't just echo out an array. You have to either use print_r() or
iterate over it with a while or for...next loop. But if you just want to see
what's in the array, print_r() it.

As to why it doesn't bring over the other checkboxes...

If you have (pseudocode)


 Checkbox 1
 Checkbox 2
 Checkbox 3



And you check the first two checkboxes, then the resulting array will be
(pseudocode again):
completed(value1,value2)

And from there, you just access the array contents as you would with any
other multidimensional array.

If you don't check anything on the page, then the array will be empty and, I
think, won't even be sent in the $_POST array. I'm sure somebody will
correct me there if my memory has failed me.

-Original Message-
From: Craig Hoffman [mailto:[EMAIL PROTECTED]
Sent: Friday, January 21, 2005 4:32 PM
To: php-db@lists.php.net
Cc: Richard Hutchins
Subject: Re: [PHP-DB] checkboxes


I've tried that and it still doesn't bring over the other checkboxes 
that have been checked.  Plus when I echo it out I get
Array  instead of the variable name.


On Jan 21, 2005, at 3:14 PM, Hutchins, Richard wrote:

> Probably all you need to do is name your checkboxes as an array thusly:
>
> name="completed[]"
>
> Then you can access the array on your update page and do whatever you 
> wish
> with it.
>
> Hope this helps.
>
> Rich
>
> -Original Message-
> From: Craig Hoffman [mailto:[EMAIL PROTECTED]
> Sent: Friday, January 21, 2005 4:03 PM
> To: php-db@lists.php.net
> Subject: [PHP-DB] checkboxes
>
>
> I have a form that display's a checkbox if the value is NULL. The form
> is in a do... while loop, so the user may check multiple checkboxes.
> I am trying to pass the variable of each checkboxes to an update
> statement in MySQL.  THe problem is I am only getting one of the
> checkboxes, even if all of them are checked.  Here is my code block,
> any help would be great.  - Craig
>
> //From form page
> 
>   
> 
>
> //MySQL Update Page
> $email = $_POST['email'] == $route;
>   $completed = $_POST["completed"] == $route;
>$route_name = trim($_POST["route_name"]) == $route;
>   $user_id = $_POST['user_id'] == $route;
>   $id = $_POST['id'] == $route;
>
> $route = array(id => "$_POST[id]", completed => "$_POST[completed]",
> route_name => "$_POST[route_name]", user_id => "$_POST[user_id]");
>
>  foreach ($route as $key => $values) {
> echo("");
> echo $values;
>//MySQL Update statement will go here.
>   }
>
> -- 
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
> -- 
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] checkboxes

2005-01-21 Thread Craig Hoffman
I've tried that and it still doesn't bring over the other checkboxes 
that have been checked.  Plus when I echo it out I get
Array  instead of the variable name.

On Jan 21, 2005, at 3:14 PM, Hutchins, Richard wrote:
Probably all you need to do is name your checkboxes as an array thusly:
name="completed[]"
Then you can access the array on your update page and do whatever you 
wish
with it.

Hope this helps.
Rich
-Original Message-
From: Craig Hoffman [mailto:[EMAIL PROTECTED]
Sent: Friday, January 21, 2005 4:03 PM
To: php-db@lists.php.net
Subject: [PHP-DB] checkboxes
I have a form that display's a checkbox if the value is NULL. The form
is in a do... while loop, so the user may check multiple checkboxes.
I am trying to pass the variable of each checkboxes to an update
statement in MySQL.  THe problem is I am only getting one of the
checkboxes, even if all of them are checked.  Here is my code block,
any help would be great.  - Craig
//From form page

  

//MySQL Update Page
$email = $_POST['email'] == $route;
$completed = $_POST["completed"] == $route;
 $route_name = trim($_POST["route_name"]) == $route;
$user_id = $_POST['user_id'] == $route;
$id = $_POST['id'] == $route;
$route = array(id => "$_POST[id]", completed => "$_POST[completed]",
route_name => "$_POST[route_name]", user_id => "$_POST[user_id]");
 foreach ($route as $key => $values) {
echo("");
echo $values;
   //MySQL Update statement will go here.
}
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP-DB] checkboxes

2005-01-21 Thread Hutchins, Richard
Probably all you need to do is name your checkboxes as an array thusly:

name="completed[]"

Then you can access the array on your update page and do whatever you wish
with it.

Hope this helps.

Rich

-Original Message-
From: Craig Hoffman [mailto:[EMAIL PROTECTED]
Sent: Friday, January 21, 2005 4:03 PM
To: php-db@lists.php.net
Subject: [PHP-DB] checkboxes


I have a form that display's a checkbox if the value is NULL. The form 
is in a do... while loop, so the user may check multiple checkboxes.
I am trying to pass the variable of each checkboxes to an update 
statement in MySQL.  THe problem is I am only getting one of the 
checkboxes, even if all of them are checked.  Here is my code block, 
any help would be great.  - Craig

//From form page

  


//MySQL Update Page
$email = $_POST['email'] == $route;
$completed = $_POST["completed"] == $route;
 $route_name = trim($_POST["route_name"]) == $route;
$user_id = $_POST['user_id'] == $route;
$id = $_POST['id'] == $route;

$route = array(id => "$_POST[id]", completed => "$_POST[completed]", 
route_name => "$_POST[route_name]", user_id => "$_POST[user_id]");

 foreach ($route as $key => $values) {
echo("");
echo $values;
   //MySQL Update statement will go here.
}

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Checkboxes on repeat regions

2004-12-06 Thread Jason Wong
On Monday 06 December 2004 20:39, Stuart Felenstein wrote:

> --- Jason Wong <[EMAIL PROTECTED]> wrote:
> > I'm not sure what you mean exactly by "intended use
> > checkboxes".
>
> Intended use - I generate a list (via a repeat region)
> of records.  Each item on the list has an associated
> checkbox. If I put a check in the box, do a $_POST I
> expect on the next page where I"ve set up the correct
> parameters, to see the selected record only.

OK, so your intended use is to "see the selected record(s?)" (based on the 
checkboxes selected). Now your problem is not with the "see selected record" 
bit (I'm pretty sure you've got that sussed out), it is with "how do I handle 
checkboxes". See below.

> Probably, but then again all questions posted here
> could be derived from the manual.

I would guess that 80% of the questions on the list could be answered with 
_direct_ reference to the manual(s). By direct reference I mean either 
searching the manual for the 1 or 2 _obvious_ keywords or looking in the 
_obvious_ section of the manual. For example, some people have asked "how do 
I escape strings before inserting them into a mysql database", well one of 
the obvious place would be to look at the mysql section of the php manual, 
and if the asker had done that they would have seen that there are functions 
called mysql_real_escape_string() and mysql_escape_string(). That's why 
people should RTFM first, before even thinking of posting to the list!

Anyway ...

> So I set the value of the check box to:
>  name="checkbox" value=" $rsRes->Fields('Rese'); ?>">

... there's your problem, all your checkboxes have the same name. PHP is not 
smart enough to automatically put them into an array, so if you check more 
than one checkbox PHP will either keep the first checkbox or the last 
checkbox (I don't know the exact behaviour (and don't care) but you can 
easily do some tests to find out should you wish).

> While it returns from the correct field it is not
> returning the correct record.  I read somewhere to
> name checkbox as an array.  checkbox[]
> Perhaps this is what I need to do.

Indeed, that is what the manual hints at, and what the articles will tell you 
to do.

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-db
--
/*
Okay ... I'm going home to write the "I HATE RUBIK's CUBE HANDBOOK FOR
DEAD CAT LOVERS" ...
*/

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Checkboxes on repeat regions

2004-12-06 Thread Stuart Felenstein

--- Jason Wong <[EMAIL PROTECTED]> wrote:

> I'm not sure what you mean exactly by "intended use
> checkboxes". 

Intended use - I generate a list (via a repeat region)
of records.  Each item on the list has an associated
checkbox. If I put a check in the box, do a $_POST I
expect on the next page where I"ve set up the correct
parameters, to see the selected record only.


> How to implement using PHP:...again this stuff
is in the manual;

Probably, but then again all questions posted here
could be derived from the manual.
> 

So I set the value of the check box to: 


(and by the way, that is Adoob syntax, so don't let
the value throw you)

While it returns from the correct field it is not
returning the correct record.  I read somewhere to
name checkbox as an array.  checkbox[]
Perhaps this is what I need to do. 

Stuart

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Checkboxes on repeat regions

2004-12-06 Thread Jason Wong
On Monday 06 December 2004 18:11, Stuart Felenstein wrote:

> Okay, I'll take a look.  Usually, as in this case, I
> did perform an extensive search for an answer.  I did
> not find one however that really addressed my
> particular intended use of checkboxes.  Many articles,
> forum post, etc were about "deletes" and insertions
> using checkboxes.

I'm not sure what you mean exactly by "intended use checkboxes". Let's try to 
break it down:

Purpose: check boxes are used to select one or more values/options/choices

How to implement using PHP: you need to know how to output the correct HTML so 
that it will be easy to process - this is covered in the manual; you need to 
know how to process the submitted form and read the values from the 
checkboxes - again this stuff is in the manual;

What to do depending on the values of checkboxes: this is probably what you 
meant by "deletes" and "insertions". Well, as along as you know *how* to read 
the values from checkboxes then *what* you do with them is a completely 
separate issue. Just because one article uses checkboxes to "delete stuff" it 
doesn't mean you can't use the overall principle and change the code to 
"delete stuff" into "display stuff".

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-db
--
/*
Don't get stuck in a closet -- wear yourself out.
*/

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Checkboxes on repeat regions

2004-12-06 Thread Stuart Felenstein

--- Jason Wong <[EMAIL PROTECTED]> wrote:

> I understand from your previous postings that you
> use Dreamweaver (to do at 
> least part of your coding). If you are at all
> serious about coding with PHP 
> (ie you want to do stuff that is any more advanced
> than the most basic stuff) 
> then you should ditch Dreamweaver (or only use it as
> an straightforward 
> editor and project manager). The code produced by
> Dreamweaver will be 
> (because of its generic nature) any one or more of
> these: convoluted, 
> obfuscated, non-obvious, overly lengthy.

I've read varying opinions and reviews about
Dreamweaver as a PHP editor / code generator.  Being
that I am not experienced with PHP to any large degree
my opinion may not count here.  What I have found
though in learning more about PHP is that the
Dreamweaver code is actually pretty straightforward. 
I won't disagree with the above statements, but
believe that for many (or some) things, it can speed
up development time.  Usually hand coding and
modifications though are required for things outside
of the standard "functionality".  


>   google > html checkbox php
> 
> In particular the IBM developerworks article looks
> like ideal reading for you.
> 
Okay, I'll take a look.  Usually, as in this case, I
did perform an extensive search for an answer.  I did
not find one however that really addressed my
particular intended use of checkboxes.  Many articles,
forum post, etc were about "deletes" and insertions
using checkboxes.  

Stuart

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Checkboxes on repeat regions

2004-12-06 Thread Jason Wong
On Sunday 05 December 2004 20:53, Stuart Felenstein wrote:

> I have this form that is set up like this:

[snip]

I understand from your previous postings that you use Dreamweaver (to do at 
least part of your coding). If you are at all serious about coding with PHP 
(ie you want to do stuff that is any more advanced than the most basic stuff) 
then you should ditch Dreamweaver (or only use it as an straightforward 
editor and project manager). The code produced by Dreamweaver will be 
(because of its generic nature) any one or more of these: convoluted, 
obfuscated, non-obvious, overly lengthy.

Writing your own code will (hopefully) allow you to understand what you're 
doing, and why you're doing it.

> I'm having no luck though and perhaps I'm unclear
> about  the use of checkboxes or even radio buttons.

  google > html checkbox php

In particular the IBM developerworks article looks like ideal reading for you.

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-db
--
/*
Hard reality has a way of cramping your style.
  -- Daniel Dennett
*/

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] checkboxes and loops

2004-03-29 Thread John W. Holmes
matthew perry wrote:


$counter++;

*Bad solution 2 (doesn't work)***
$counter = 1;
while (<>)
{
if ($box . $counter == 'delete')   <>
$counter++;
}
***
if(${$box . $counter} == 'delete')

However, like someone else said, if you named your checkboxes as box[1], 
box[2], etc, then you'd have a nice $_POST['box'] array that you could 
loop through.

foreach($_POST['box'] as $count => $value)
{ do_whatever($count); }
--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

php|architect: The Magazine for PHP Professionals – www.phparch.com

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP-DB] checkboxes and loops

2004-03-29 Thread Duane Lakoduk
I am relatively new with PHP, but have done this many times with ASP.
First, I would not assign the counter value to the checkbox as you are now.
Use the ID (identity) value from the database for the applicant record
instead.  Since ONLY the checkboxes that are checked will be submitted, you
can just loop through the submitted checkbox values and perform a 'delete',
or 'whatever' on each submitted record.  Or, use: "...WHERE IN (id1, id2,
..., idN)" in your DELETE statement.

Duane



> -Original Message-
> From: matthew perry [mailto:[EMAIL PROTECTED]
> Sent: Sunday, March 28, 2004 11:45 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP-DB] checkboxes and loops
>
>
> OK lets see if I can figure out how to ask this:
>
> I am setting up a system for my company to filter through employee
> applications.  Most of the applications do not fit the criteria and I
> want to allow my bosses a checkbox to the right of them which
> they can
> check or uncheck to remove an applicant.
> So I run a loop that generates a bunch of check boxes with the name
> box1, box2, box3... by running a loop that runs this and increments
> counter every time:
> {
>  = "delete">
> $counter++;
> }
>
> But when I try to create my query that updates the table I have a
> problem generating these variable again by referring to them
> indirectly:
>
> *Bad solution 1 (to much work)***
> if ($box1 == 'delete')   <>
> if ($box2 == 'delete')  <>
> if ($box3 == 'delete')  <>
> if ($box4 == 'delete')  <>
> if ($box5 == 'delete')  <>
> if ($box6 == 'delete')  <>
> ***
>
> *Bad solution 2 (doesn't work)***
> $counter = 1;
> while (<>)
> {
> if ($box . $counter == 'delete')   <>
> $counter++;
> }
> ***
>
> How do I get around this problem?
> Hopefully someone understands what I am trying to say.
>
> Matt
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] checkboxes and loops

2004-03-28 Thread Mikhail U. Petrov
Hi!
I think you should rename checkboxes to box[1], box[2] etc.
So you will get an array $_POST["box"]. I think it will be better.
Best wishes,
Mikhail U. Petrov,
PHP-programmer



Hello matthew,

Monday, March 29, 2004, 9:45:28 AM, you wrote:

mp> OK lets see if I can figure out how to ask this:

mp> I am setting up a system for my company to filter through employee 
mp> applications.  Most of the applications do not fit the criteria and I 
mp> want to allow my bosses a checkbox to the right of them which they can 
mp> check or uncheck to remove an applicant.
mp> So I run a loop that generates a bunch of check boxes with the name 
mp> box1, box2, box3... by running a loop that runs this and increments 
mp> counter every time:
mp> {
mp> 
mp> $counter++;
mp> }

mp> But when I try to create my query that updates the table I have a 
mp> problem generating these variable again by referring to them indirectly:

mp> *Bad solution 1 (to much work)***
mp> if ($box1 == 'delete')   <>
mp> if ($box2 == 'delete')  <>
mp> if ($box3 == 'delete')  <>
mp> if ($box4 == 'delete')  <>
mp> if ($box5 == 'delete')  <>
mp> if ($box6 == 'delete')  <>
mp> ***

mp> *Bad solution 2 (doesn't work)***
mp> $counter = 1;
mp> while (<>)
mp> {
mp> if ($box . $counter == 'delete')   <>
mp> $counter++;
mp> }
mp> ***

mp> How do I get around this problem?
mp> Hopefully someone understands what I am trying to say.

mp> Matt

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Checkboxes to gather rows to delete

2003-02-25 Thread Lewis Watson

- Original Message -
From: "Lewis Watson" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, February 24, 2003 9:35 AM
Subject: [PHP-DB] Checkboxes to gather rows to delete


> I have a mysql database with a table using one column as a primary key.
> (rowID). On a php page I use a query to  list all of the rows of the
table
> and have a checkbox beside each  row that should be used to check if you
> would like to delete this row. Can someone give me an example using post
> to pull the boxes that need to be deleted.
> Thanks!
> Lewis



I appreciate everyones help. Below what I ended up with to actually delete
the checked boxes.
Lewis

// Deletes specified rows by teacherID.
if(isset($delete_teacher) && isset($deleteID)) {

while (list($key, $num)= each($_POST[deleteID])){

$delete_query = mysql_query("delete from
teacher where teacherID = $num");
print $delete_query;
print "";
}
}

//Checkbox and Submit lines...
 print "";

 print "";


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Checkboxes to gather rows to delete

2003-02-24 Thread 1LT John W. Holmes
> I think the problem is that I need to put the array into a comma delimited
> group
> Lewis

U... that's what IMPLODE does. It will take the array and turn it into a
comma separated list. Your having a problem because you're not passing an
array when you think you are.

---John Holmes...

> - Original Message -
> From: "John W. Holmes" <[EMAIL PROTECTED]>
> To: "'Lewis Watson'" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
> Sent: Monday, February 24, 2003 11:09 AM
> Subject: RE: [PHP-DB] Checkboxes to gather rows to delete
>
>
> > > Hi there,
> > > I have double checked the column namesIts giving me a Warning: Bad
> > > arguments to implode() error
> > > Thanks.
> > > Lewis
> >
> > What's the code you're using? Are you sure $deleteID is an array at the
> > point you call implode()? Are you sure it's available in the current
> > scope at the point you call implode()?
> >
> > ---John W. Holmes...
> >
> > PHP Architect - A monthly magazine for PHP Professionals. Get your copy
> > today. http://www.phparch.com/
> >
> > >
> > > - Original Message -
> > > From: "1LT John W. Holmes" <[EMAIL PROTECTED]>
> > > To: "Lewis Watson" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
> > > Sent: Monday, February 24, 2003 10:36 AM
> > > Subject: Re: [PHP-DB] Checkboxes to gather rows to delete
> > >
> > >
> > > > > Thanks. The below code returns each ID in an array like so...
> > > > > Array ( [0] =>101 [1] => 201 ). Thanks for the help!
> > > > > Lewis
> > > > >
> > > > > $teacherID = $_POST[teacherID];
> > > > > $deleteID = $_POST[deleteID];
> > > > >
> > > > > if(isset($delete_teacher)) {
> > > > >   This is where I should loop through checking for the chosen
> > ones
> > > to
> > > > > delete.
> > > >
> > > > $query = "DELETE FROM table WHERE teacherID IN (" .
> > > implode(',',$deleteID) .
> > > > ")";
> > > > mysql_query($query);
> > > >
> > > > > }
> > > > >
> > > > > 
> > > > >  print " > > > > value=\"$row[teacherID]\">";
> > > > >  print " > value=\"Delete
> > > the
> > > > > Checked Teachers\">";
> > > >
> > > > Make sure the column names are correct, but that's it.
> > > >
> > > > ---John Holmes...
> > > >
> > > >
> > >
> > >
> > > --
> > > PHP Database Mailing List (http://www.php.net/)
> > > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
> >
> >
> > --
> > PHP Database Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Checkboxes to gather rows to delete

2003-02-24 Thread Lewis Watson
I think the problem is that I need to put the array into a comma delimited
group
Lewis

- Original Message -
From: "John W. Holmes" <[EMAIL PROTECTED]>
To: "'Lewis Watson'" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Monday, February 24, 2003 11:09 AM
Subject: RE: [PHP-DB] Checkboxes to gather rows to delete


> > Hi there,
> > I have double checked the column namesIts giving me a Warning: Bad
> > arguments to implode() error
> > Thanks.
> > Lewis
>
> What's the code you're using? Are you sure $deleteID is an array at the
> point you call implode()? Are you sure it's available in the current
> scope at the point you call implode()?
>
> ---John W. Holmes...
>
> PHP Architect - A monthly magazine for PHP Professionals. Get your copy
> today. http://www.phparch.com/
>
> >
> > - Original Message -
> > From: "1LT John W. Holmes" <[EMAIL PROTECTED]>
> > To: "Lewis Watson" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
> > Sent: Monday, February 24, 2003 10:36 AM
> > Subject: Re: [PHP-DB] Checkboxes to gather rows to delete
> >
> >
> > > > Thanks. The below code returns each ID in an array like so...
> > > > Array ( [0] =>101 [1] => 201 ). Thanks for the help!
> > > > Lewis
> > > >
> > > > $teacherID = $_POST[teacherID];
> > > > $deleteID = $_POST[deleteID];
> > > >
> > > > if(isset($delete_teacher)) {
> > > >   This is where I should loop through checking for the chosen
> ones
> > to
> > > > delete.
> > >
> > > $query = "DELETE FROM table WHERE teacherID IN (" .
> > implode(',',$deleteID) .
> > > ")";
> > > mysql_query($query);
> > >
> > > > }
> > > >
> > > > 
> > > >  print " > > > value=\"$row[teacherID]\">";
> > > >  print " value=\"Delete
> > the
> > > > Checked Teachers\">";
> > >
> > > Make sure the column names are correct, but that's it.
> > >
> > > ---John Holmes...
> > >
> > >
> >
> >
> > --
> > PHP Database Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP-DB] Checkboxes to gather rows to delete

2003-02-24 Thread John W. Holmes
> Hi there,
> I have double checked the column namesIts giving me a Warning: Bad
> arguments to implode() error
> Thanks.
> Lewis

What's the code you're using? Are you sure $deleteID is an array at the
point you call implode()? Are you sure it's available in the current
scope at the point you call implode()?

---John W. Holmes...

PHP Architect - A monthly magazine for PHP Professionals. Get your copy
today. http://www.phparch.com/

> 
> - Original Message -
> From: "1LT John W. Holmes" <[EMAIL PROTECTED]>
> To: "Lewis Watson" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
> Sent: Monday, February 24, 2003 10:36 AM
> Subject: Re: [PHP-DB] Checkboxes to gather rows to delete
> 
> 
> > > Thanks. The below code returns each ID in an array like so...
> > > Array ( [0] =>101 [1] => 201 ). Thanks for the help!
> > > Lewis
> > >
> > > $teacherID = $_POST[teacherID];
> > > $deleteID = $_POST[deleteID];
> > >
> > > if(isset($delete_teacher)) {
> > >   This is where I should loop through checking for the chosen
ones
> to
> > > delete.
> >
> > $query = "DELETE FROM table WHERE teacherID IN (" .
> implode(',',$deleteID) .
> > ")";
> > mysql_query($query);
> >
> > > }
> > >
> > > 
> > >  print " > > value=\"$row[teacherID]\">";
> > >  print " the
> > > Checked Teachers\">";
> >
> > Make sure the column names are correct, but that's it.
> >
> > ---John Holmes...
> >
> >
> 
> 
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php




-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Checkboxes to gather rows to delete

2003-02-24 Thread Jason Wong
On Monday 24 February 2003 23:57, George Pitcher wrote:

> Can I raise a point of principle here.
>
> My databases never have records deleted - instead they are marked as being
> deleted in a status field. That way, they are always there for reference.
>
> Unless you are running a system that needs the space or has extremely high
> turnover of deleted records, this makes sesne.

Better still, setup parallel tables and move deleted records over. That way 
you'll save cluttering up the main tables.

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-db
--
/*
A diplomat's life consists of three things: protocol, Geritol, and alcohol.
-- Adlai Stevenson
*/


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Checkboxes to gather rows to delete

2003-02-24 Thread Lewis Watson
Hi there,
I have double checked the column namesIts giving me a Warning: Bad
arguments to implode() error
Thanks.
Lewis

- Original Message -
From: "1LT John W. Holmes" <[EMAIL PROTECTED]>
To: "Lewis Watson" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Monday, February 24, 2003 10:36 AM
Subject: Re: [PHP-DB] Checkboxes to gather rows to delete


> > Thanks. The below code returns each ID in an array like so...
> > Array ( [0] =>101 [1] => 201 ). Thanks for the help!
> > Lewis
> >
> > $teacherID = $_POST[teacherID];
> > $deleteID = $_POST[deleteID];
> >
> > if(isset($delete_teacher)) {
> >   This is where I should loop through checking for the chosen ones
to
> > delete.
>
> $query = "DELETE FROM table WHERE teacherID IN (" .
implode(',',$deleteID) .
> ")";
> mysql_query($query);
>
> > }
> >
> > 
> >  print " > value=\"$row[teacherID]\">";
> >  print " > Checked Teachers\">";
>
> Make sure the column names are correct, but that's it.
>
> ---John Holmes...
>
>


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Checkboxes to gather rows to delete

2003-02-24 Thread 1LT John W. Holmes
> Thanks. The below code returns each ID in an array like so...
> Array ( [0] =>101 [1] => 201 ). Thanks for the help!
> Lewis
>
> $teacherID = $_POST[teacherID];
> $deleteID = $_POST[deleteID];
>
> if(isset($delete_teacher)) {
>   This is where I should loop through checking for the chosen ones to
> delete.

$query = "DELETE FROM table WHERE teacherID IN (" . implode(',',$deleteID) .
")";
mysql_query($query);

> }
>
> 
>  print " value=\"$row[teacherID]\">";
>  print " Checked Teachers\">";

Make sure the column names are correct, but that's it.

---John Holmes...


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Checkboxes to gather rows to delete

2003-02-24 Thread Lewis Watson
Thanks. The below code returns each ID in an array like so...
Array ( [0] =>101 [1] => 201 ). Thanks for the help!
Lewis

$teacherID = $_POST[teacherID];
$deleteID = $_POST[deleteID];

if(isset($delete_teacher)) {
  This is where I should loop through checking for the chosen ones to
delete.

}


 print "";
 print "";


- Original Message -
From: "1LT John W. Holmes" <[EMAIL PROTECTED]>
To: "Lewis Watson" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Monday, February 24, 2003 10:21 AM
Subject: Re: [PHP-DB] Checkboxes to gather rows to delete


> > Thats just it. I am just not sure what to do with the array before my
> > "delete from" query now that I have it :-)
> > Thanks...
> > Lewis
>
> You don't have to do anything with it, just throw it into the line that
I
> gave you. Show the code you have now and someone can help you put it all
> together.
>
> ---John Holmes...
>
> > - Original Message -
> > From: "1LT John W. Holmes" <[EMAIL PROTECTED]>
> > To: "Lewis Watson" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
> > Sent: Monday, February 24, 2003 10:13 AM
> > Subject: Re: [PHP-DB] Checkboxes to gather rows to delete
> >
> >
> > > > I appreciate all of the quick replies. I do have globals off.
> > Currently, I
> > > > have the values for each ID being returned in a array Array
( [0]
> > =>
> > > > 101 [1] => 201 )  where 101 and 201 were the id's of the rows I
> > checked. I
> > > > have to say I like the way of doing it that Mathieu has shown
using
> > the
> > > > explode function.
> > > > Thanks again.
> > > > Lewis
> > >
> > > You already have an array of IDs you want to delete. Explode is for
> > making
> > > arrays, so what would you use it on? That doesn't make sense.
> > >
> > > $query = "DELETE FROM table WHERE rowID IN (" .
> > > implode(',',$_POST['id_array']) . ")";
> > >
> > > is the most efficient, easiest solution, but use whatever you
> > understand.
> > >
> > > ---John Holmes...
> > >
> >
> >
> > --
> > PHP Database Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Checkboxes to gather rows to delete

2003-02-24 Thread 1LT John W. Holmes
> Thats just it. I am just not sure what to do with the array before my
> "delete from" query now that I have it :-)
> Thanks...
> Lewis

You don't have to do anything with it, just throw it into the line that I
gave you. Show the code you have now and someone can help you put it all
together.

---John Holmes...

> - Original Message -
> From: "1LT John W. Holmes" <[EMAIL PROTECTED]>
> To: "Lewis Watson" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
> Sent: Monday, February 24, 2003 10:13 AM
> Subject: Re: [PHP-DB] Checkboxes to gather rows to delete
>
>
> > > I appreciate all of the quick replies. I do have globals off.
> Currently, I
> > > have the values for each ID being returned in a array Array ( [0]
> =>
> > > 101 [1] => 201 )  where 101 and 201 were the id's of the rows I
> checked. I
> > > have to say I like the way of doing it that Mathieu has shown using
> the
> > > explode function.
> > > Thanks again.
> > > Lewis
> >
> > You already have an array of IDs you want to delete. Explode is for
> making
> > arrays, so what would you use it on? That doesn't make sense.
> >
> > $query = "DELETE FROM table WHERE rowID IN (" .
> > implode(',',$_POST['id_array']) . ")";
> >
> > is the most efficient, easiest solution, but use whatever you
> understand.
> >
> > ---John Holmes...
> >
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Checkboxes to gather rows to delete

2003-02-24 Thread Lewis Watson
Thats just it. I am just not sure what to do with the array before my
"delete from" query now that I have it :-)
Thanks...
Lewis


- Original Message -
From: "1LT John W. Holmes" <[EMAIL PROTECTED]>
To: "Lewis Watson" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Monday, February 24, 2003 10:13 AM
Subject: Re: [PHP-DB] Checkboxes to gather rows to delete


> > I appreciate all of the quick replies. I do have globals off.
Currently, I
> > have the values for each ID being returned in a array Array ( [0]
=>
> > 101 [1] => 201 )  where 101 and 201 were the id's of the rows I
checked. I
> > have to say I like the way of doing it that Mathieu has shown using
the
> > explode function.
> > Thanks again.
> > Lewis
>
> You already have an array of IDs you want to delete. Explode is for
making
> arrays, so what would you use it on? That doesn't make sense.
>
> $query = "DELETE FROM table WHERE rowID IN (" .
> implode(',',$_POST['id_array']) . ")";
>
> is the most efficient, easiest solution, but use whatever you
understand.
>
> ---John Holmes...
>


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Checkboxes to gather rows to delete

2003-02-24 Thread 1LT John W. Holmes
> I appreciate all of the quick replies. I do have globals off. Currently, I
> have the values for each ID being returned in a array Array ( [0] =>
> 101 [1] => 201 )  where 101 and 201 were the id's of the rows I checked. I
> have to say I like the way of doing it that Mathieu has shown using the
> explode function.
> Thanks again.
> Lewis

You already have an array of IDs you want to delete. Explode is for making
arrays, so what would you use it on? That doesn't make sense.

$query = "DELETE FROM table WHERE rowID IN (" .
implode(',',$_POST['id_array']) . ")";

is the most efficient, easiest solution, but use whatever you understand.

---John Holmes...


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Checkboxes to gather rows to delete

2003-02-24 Thread Lewis Watson
I appreciate all of the quick replies. I do have globals off. Currently, I
have the values for each ID being returned in a array Array ( [0] =>
101 [1] => 201 )  where 101 and 201 were the id's of the rows I checked. I
have to say I like the way of doing it that Mathieu has shown using the
explode function.
Thanks again.
Lewis


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP-DB] Checkboxes to gather rows to delete

2003-02-24 Thread George Pitcher
Hi all,

Can I raise a point of principle here.

My databases never have records deleted - instead they are marked as being
deleted in a status field. That way, they are always there for reference.

Unless you are running a system that needs the space or has extremely high
turnover of deleted records, this makes sesne.

Just my 2c.

George in Oxford

> -Original Message-
> From: Mathieu Dumoulin [mailto:[EMAIL PROTECTED]
> Sent: 24 February 2003 3:49 pm
> To: [EMAIL PROTECTED]
> Subject: Re: [PHP-DB] Checkboxes to gather rows to delete
>
>
> It is wrong to use that way of doing it John, cause this will delete ALL
> lines that where printed with a checkbox
> And also, if you are using a old version of PHP with register globals OFF,
> the _POST array will not be available
>
> Mathieu Dumoulin
>
> "1lt John W. Holmes" <[EMAIL PROTECTED]> a écrit dans le message de
> news: [EMAIL PROTECTED]
> > > I have a mysql database with a table using one column as a
> primary key.
> > > (rowID). On a php page I use a query to  list all of the rows of the
> table
> > > and have a checkbox beside each  row that should be used to
> check if you
> > > would like to delete this row. Can someone give me an example
> using post
> > > to pull the boxes that need to be deleted.
> >
> > Easy one.. :)
> >
> > Make sure your checkboxes have the rowID as their value, then you can
> simply
> > do this:
> >
> > $query = "DELETE FROM table WHERE rowID IN (" .
> > implode(',',$_POST['checkboxes']) . ")";
> >
> > and run that query.
> >
> > You'll end up with something that looks like this:
> >
> > DELETE FROM table WHERE rowID IN (1,2,3,4,5)
> >
> > where the numbers will come from only the checkboxes that you selected.
> >
> > ---John Holmes...
> >
>
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Checkboxes to gather rows to delete

2003-02-24 Thread Mathieu Dumoulin
It is wrong to use that way of doing it John, cause this will delete ALL
lines that where printed with a checkbox
And also, if you are using a old version of PHP with register globals OFF,
the _POST array will not be available

Mathieu Dumoulin

"1lt John W. Holmes" <[EMAIL PROTECTED]> a écrit dans le message de
news: [EMAIL PROTECTED]
> > I have a mysql database with a table using one column as a primary key.
> > (rowID). On a php page I use a query to  list all of the rows of the
table
> > and have a checkbox beside each  row that should be used to check if you
> > would like to delete this row. Can someone give me an example using post
> > to pull the boxes that need to be deleted.
>
> Easy one.. :)
>
> Make sure your checkboxes have the rowID as their value, then you can
simply
> do this:
>
> $query = "DELETE FROM table WHERE rowID IN (" .
> implode(',',$_POST['checkboxes']) . ")";
>
> and run that query.
>
> You'll end up with something that looks like this:
>
> DELETE FROM table WHERE rowID IN (1,2,3,4,5)
>
> where the numbers will come from only the checkboxes that you selected.
>
> ---John Holmes...
>



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Checkboxes to gather rows to delete

2003-02-24 Thread 1LT John W. Holmes
> I have a mysql database with a table using one column as a primary key.
> (rowID). On a php page I use a query to  list all of the rows of the table
> and have a checkbox beside each  row that should be used to check if you
> would like to delete this row. Can someone give me an example using post
> to pull the boxes that need to be deleted.

Easy one.. :)

Make sure your checkboxes have the rowID as their value, then you can simply
do this:

$query = "DELETE FROM table WHERE rowID IN (" .
implode(',',$_POST['checkboxes']) . ")";

and run that query.

You'll end up with something that looks like this:

DELETE FROM table WHERE rowID IN (1,2,3,4,5)

where the numbers will come from only the checkboxes that you selected.

---John Holmes...


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] checkboxes names & values in mySQL (newbie)

2002-10-10 Thread Andrey Sosnitsky

Hello, John.

You wrote 10 îêòÿáðÿ 2002 ã., 23:40:10:

J> 2 questions:
J> Should  I have a unique form name for each checkbox, and store it's
J> boolean value in the database, OR (is it more streamlined) ..

J> To   create   an   array=myarray[$i]>  with  the  same  name  but  different value for each
J> checkbox.
Yes, you are right. This is a good way, to create an array.

J> Finally, how do I construct the query to store the array of values?
J> Do  I  need  a  separate  column  (enum('n','y') for each value, or
J> should I store all the true values as a long text string?
It'll be nice to store values separetly each in row.

Smth like this

INSERT INTO table (apps, value) VALUES ('apps', '$value[1]');
INSERT INTO table (apps, value) VALUES ('apps', '$value[2]');
etc.

Then, you can manupulate those values as you want.

www.pskov.ruwebmaster|programmer|DBA
www.invest.pskov.ru
www.education.pskov.ru
-- 
Best Regards,
Andrey  mailto:[EMAIL PROTECTED]



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DB] Checkboxes, PHP, and MySQL

2001-12-20 Thread Jim Lucas

Try this

>

Jim
- Original Message -
From: "SpyProductions Support Team" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, December 20, 2001 8:40 AM
Subject: [PHP-DB] Checkboxes, PHP, and MySQL


>
> I've looked around in a few of the PHP lists for an answer to this, but
> can't come up with one.
>
> Here's what I am doing:
>
> I have a form with a few checkboxes.
>
> When the information as to whether the checkboxes are checked or not is
> 'saved' into the MySQL table, they are represented by a value of '1' -
fine.
>
> When I want to edit this information, in the form of a similar form with
> checkboxes, the boxes are not checked off if they were before.
>
> What I am stuck on is how a checkbox can get checked off when pulling
> information from the MySQL as an array.
>
> Here's a line of code showing my array coming out.
>
> 
>
> $result is the array.
>
> I guess what I am asking is that if a checkbox is assigned a value of one,
> why doesn't it appear as already checked off?
>
> Thanks,
>
> -Mike
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>
>


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] Checkboxes, PHP, and MySQL

2001-12-20 Thread Pierre-Alain Joye

Only one link should solve your problem :) 
http://www.w3.org/TR/html401/interact/forms.html#h-17.4

HTH

pa

-- 
Pierre-Alain Joye
Freelance
Developpements et Services web/intranet
[EMAIL PROTECTED]

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP-DB] Checkboxes, PHP, and MySQL

2001-12-20 Thread Jonathan Hilgeman

Or a better, more-visual way might be:

";
?>

- Jonathan

-Original Message-
From: matt stewart [mailto:[EMAIL PROTECTED]]
Sent: Thursday, December 20, 2001 8:45 AM
To: '[EMAIL PROTECTED]'; [EMAIL PROTECTED]
Subject: RE: [PHP-DB] Checkboxes, PHP, and MySQL


the value doesn't determine whether it's checked or not - it determines the
value passed WHEN it's checked.
try the lines below:
echo"";
}else{
echo">";
}
or something along these lines.

-Original Message-
From: SpyProductions Support Team [mailto:[EMAIL PROTECTED]]
Sent: 20 December 2001 16:40
To: [EMAIL PROTECTED]
Subject: [PHP-DB] Checkboxes, PHP, and MySQL



I've looked around in a few of the PHP lists for an answer to this, but
can't come up with one.

Here's what I am doing:

I have a form with a few checkboxes.

When the information as to whether the checkboxes are checked or not is
'saved' into the MySQL table, they are represented by a value of '1' - fine.

When I want to edit this information, in the form of a similar form with
checkboxes, the boxes are not checked off if they were before.

What I am stuck on is how a checkbox can get checked off when pulling
information from the MySQL as an array.

Here's a line of code showing my array coming out.



$result is the array.

I guess what I am asking is that if a checkbox is assigned a value of one,
why doesn't it appear as already checked off?

Thanks,

-Mike


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.307 / Virus Database: 168 - Release Date: 11/12/01
 

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.307 / Virus Database: 168 - Release Date: 11/12/01
 

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] Checkboxes, PHP, and MySQL

2001-12-20 Thread Jason Wong

On Friday 21 December 2001 00:40, SpyProductions Support Team wrote:
> I've looked around in a few of the PHP lists for an answer to this, but
> can't come up with one.
>
> Here's what I am doing:
>
> I have a form with a few checkboxes.
>
> When the information as to whether the checkboxes are checked or not is
> 'saved' into the MySQL table, they are represented by a value of '1' -
> fine.
>
> When I want to edit this information, in the form of a similar form with
> checkboxes, the boxes are not checked off if they were before.
>
> What I am stuck on is how a checkbox can get checked off when pulling
> information from the MySQL as an array.
>
> Here's a line of code showing my array coming out.
>
> 
>
> $result is the array.
>
> I guess what I am asking is that if a checkbox is assigned a value of one,
> why doesn't it appear as already checked off?

value='XXX' only specifies what the value would be *if* the checkbox was 
checked. To actually *set* the checkbox you need:

 

hth
-- 
Jason Wong -> Gremlins Associates -> www.gremlins.com.hk

/*
Always there remain portions of our heart into which no one is able to enter,
invite them as we may.
*/

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP-DB] Checkboxes, PHP, and MySQL

2001-12-20 Thread matt stewart

the value doesn't determine whether it's checked or not - it determines the
value passed WHEN it's checked.
try the lines below:
echo"";
}else{
echo">";
}
or something along these lines.

-Original Message-
From: SpyProductions Support Team [mailto:[EMAIL PROTECTED]]
Sent: 20 December 2001 16:40
To: [EMAIL PROTECTED]
Subject: [PHP-DB] Checkboxes, PHP, and MySQL



I've looked around in a few of the PHP lists for an answer to this, but
can't come up with one.

Here's what I am doing:

I have a form with a few checkboxes.

When the information as to whether the checkboxes are checked or not is
'saved' into the MySQL table, they are represented by a value of '1' - fine.

When I want to edit this information, in the form of a similar form with
checkboxes, the boxes are not checked off if they were before.

What I am stuck on is how a checkbox can get checked off when pulling
information from the MySQL as an array.

Here's a line of code showing my array coming out.



$result is the array.

I guess what I am asking is that if a checkbox is assigned a value of one,
why doesn't it appear as already checked off?

Thanks,

-Mike


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.307 / Virus Database: 168 - Release Date: 11/12/01
 

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.307 / Virus Database: 168 - Release Date: 11/12/01
 

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP-DB] Checkboxes, PHP, and MySQL

2001-12-20 Thread Jonathan Hilgeman

It's not the checkbox's VALUE attribute that determines whether it is
checked or not. If you add the empty attribute CHECKED, then the checkbox
will be checked.

Example:




VarCheck1 will be checked, and VarCheck2 will not be checked. A checkbox
will only have a value on submission IF IT IS CHECKED. So if the above two
boxes were submitted and VarCheck1 was checked and VarCheck2 was not
checked, the new page would have the variable VarCheck1 containing "Good",
while VarCheck2 would be empty/non-existent. 

- Jonathan

-Original Message-
From: SpyProductions Support Team [mailto:[EMAIL PROTECTED]]
Sent: Thursday, December 20, 2001 8:40 AM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] Checkboxes, PHP, and MySQL



I've looked around in a few of the PHP lists for an answer to this, but
can't come up with one.

Here's what I am doing:

I have a form with a few checkboxes.

When the information as to whether the checkboxes are checked or not is
'saved' into the MySQL table, they are represented by a value of '1' - fine.

When I want to edit this information, in the form of a similar form with
checkboxes, the boxes are not checked off if they were before.

What I am stuck on is how a checkbox can get checked off when pulling
information from the MySQL as an array.

Here's a line of code showing my array coming out.



$result is the array.

I guess what I am asking is that if a checkbox is assigned a value of one,
why doesn't it appear as already checked off?

Thanks,

-Mike


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] Checkboxes, PHP, and MySQL

2001-12-20 Thread Paul DuBois

On Thu, Dec 20, 2001 at 11:40:14AM -0500, SpyProductions Support Team wrote:
> I've looked around in a few of the PHP lists for an answer to this, but
> can't come up with one.

On this question, you'd be better off just reading an HTML reference.
It doesn't matter what the value of a checkbox is.  If you want it
to appear checked when the browser displays it, you should supply a
"checked" attribute:



> 
> Here's what I am doing:
> 
> I have a form with a few checkboxes.
> 
> When the information as to whether the checkboxes are checked or not is
> 'saved' into the MySQL table, they are represented by a value of '1' - fine.
> 
> When I want to edit this information, in the form of a similar form with
> checkboxes, the boxes are not checked off if they were before.
> 
> What I am stuck on is how a checkbox can get checked off when pulling
> information from the MySQL as an array.
> 
> Here's a line of code showing my array coming out.
> 
> 
> 
> $result is the array.
> 
> I guess what I am asking is that if a checkbox is assigned a value of one,
> why doesn't it appear as already checked off?
> 
> Thanks,
> 
> -Mike

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP-DB] Checkboxes with mySQL

2001-09-07 Thread Rick Emery

You have to check each checkbox value in you selection criteria.  Somthing
like:

$query = "UPDATE articles SET pr=1 WHERE 0";
# assume $nbr is size of array $p
for($i=0; $i<$nbr;$i++)
{
if( isset($p[$i]) ) { $query .= "|| id=$p[$i] ";
}

This will construct a query that looks like:  UPDATE articles SET pr=1 WHERE
0 || id=1 || id=3 || id=4

The "0" in the WHERE clause is just a place holder; it saves a little
coding.

Hope this helps

rick

-Original Message-
From: Cilfa [mailto:[EMAIL PROTECTED]]
Sent: Friday, September 07, 2001 7:38 AM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] Checkboxes with mySQL


I have a database with articles from which I can make a selection of which
articles to show. This selection is made by a form with checkboxes.
In the mysql table is a field called "pr". If there's a "1" in this field,
the article should be shown for print, if there's a "0", it shouldn't.
 
In the code I generate a form with all the titles and checkboxes. The
checkbox values are the id's from the titles.
When I click the button, I want to see my selection.
   
The problem is this: What sql query can be used to proces the information
from the checkboxes? At the moment I use in order to change the values in
the database according to the checkbox selections:

$query = mysql_query("UPDATE articles SET pr='1' WHERE id='$p[id]'");

But it does nothing! How can I insert multiple values (from the checkbox
array) at one time in a database?

Cilfa


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]