Re: Updating Multiple rows with Combo Box! *SOLVED*

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

 



Ave,

Solved it!
Echoing the results out instead of trying out Queries really helped. What I
was basically doing wrong was, I did create an Array for the Values, but I
needed to also create an Array for the ID's for each records, which I
hadn't. 

This is the code I used for generating the Select List for each row:

          <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="" <?php if($row_tjContactFormData['hired']==NULL) {
echo "Selected"; } ?>>On Hold</option>
          </SELECT>

And this is my Query:

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

Thanks Jay... 


On 8/22/05 9:57 AM, "Jay Blanchard" <jay.blanchard@xxxxxxxxxxxxxxxxxxxxx>
wrote:

> [snip]
> register_globals are On.
> I think the problem lies in the fact that I'm trying to update multiple
> rows
> in the table, I'm not sure that my query with the UPDATE statement is
> updating all the rows with what is being set in the value of the Form
> Field.
> 
> I'm not sure.
> [/snip]
> 
> Echo the query before you run it to make sure that the values are what
> you expect...
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

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