Updating Multiple rows with Combo Box!

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Ave,

I have a table with one of the fields ³hired² having either of 3 values:
YES, NO, NULL
My application provides the administrator with all the records in the table
and I need to give him the ability to change the status of ³hired² to either
of the three values.

Previously I was using a Checkbox to update multiple rows using something
like this:

        echo "<INPUT name=\"hired[]\" type=checkbox
value=".$row_tjContactFormData['ID'].">";

And running this SQL query to update all the rows which had a checked Check
Box:

        for($i=0;$i<count($thisID);$i++) {
        $sql = "UPDATE contactdata SET hired='YES' WHERE ID='$thisID[$i]'";
        $result = mysql_query($sql) or DIE("Fatal Error: ".mysql_error());

I would display the rows with YES and NO as static records on the page,
those records with NULL would appear with a checkbox, which when Checked
would update the status to YES or left unchecked would change the status to
NO, when the form was submitted.

I need to change this application to allow the administrator to change the
status of any record to either of the three at any time. Thus, what I want
to give him is a Select list in each row, with three values, YES, NO and ON
HOLD. Where selecting YES would change the hired field value to YES, NO
would change it to NO, and ON HOLD would change it to NULL.

I¹ve tried a lot of different logical statements but it¹s not working out.
I¹m able to display the Combo Box in each row with the 3 values
corresponding to what already exists in the database, like this:

          <input type="hidden" name="thisID" value="<?php echo
$row_tjContactFormData['ID']; ?>">
          <SELECT name="hired">
          <option value="YES" <?php
if($row_tjContactFormData['hired']=="YES") { echo "Selected"; }
?>>YES</option>
          <option value="NO" <?php if($row_tjContactFormData['hired']=="NO")
{ echo "Selected"; } ?>>NO</option>
          <option value="NULL" <?php
if($row_tjContactFormData['hired']==NULL) { echo "Selected"; } ?>>On
Hold</option>
          </SELECT>

But none of my Queries are working. What I want to do is, when the form is
submitted, it should just simply update the ?hired¹ field with whatever
value has been selected for that row in the Combo Box.

Any help appreciated.

Thanks,

Rahul S. Johari
Coordinator, Internet & Administration
Informed Marketing Services Inc.
251 River Street
Troy, NY 12180

Tel: (518) 266-0909 x154
Fax: (518) 266-0909
Email: rahul@xxxxxxxxxxxxxxxxxxxx
http://www.informed-sources.com


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux