//connect to server and database
<?php
include("conf.inc");//config file for db, username...
mysql_connect($host, $mysqluser, $mysqlpwd)||die("cant find $host or
username/pwd wrong");
mysql_select_db($db)||die("$db doesnt exist or has a problem...");
//following code goes for each combobox to use
//if you have a different field for each
//combobox..otherwise
//put this at top of file
$query=mysql_query("select company from members");
?>
//start combo box
<select name="name">
<option value="">select a member to edit<br>
//code to populate combobox from db
<?php
while($edit=mysql_fetch_array($query)){
//use your variables instead of mine make sure to use the
//\" before and after all var names
echo "<option value=\"$edit[Company]\">\"$edit[Company]<br>";
}
?>
</select>


//rest of code for page here...

not that hard probably about 4 lines of code to make the box and put db
stuff in it...


still need to figure out why my update statement updates all records if
someone retypes the same value in the form though
----- Original Message -----
From: "Guru Geek" <[EMAIL PROTECTED]>
To: "Sunfire" <[EMAIL PROTECTED]>
Sent: Friday, February 07, 2003 12:08 PM
Subject: Re: [PHP] update to table errors/strange things happen


> Could I just see the section of code that populates the combo box with
database
> info?  I'm trying to do that exact same thing, but can't figure out the
code....
>
> Thanks,
> Roger
>
> Sunfire wrote:
>
> > i have a combo box on a web page that gets all the companies names from
a
> > mysql table and puts them in the combobox.. when someone picks a name
and
> > hits an edit button it takes them to a form where all the values in the
> > table fields for that record are shown as default values for the form
> > fields. my problem is when someone changes a value say the city or state
> > (but it happens with any of the fields) and if for some reason they
change
> > it to the same value that was already in the record then all of the
records
> > get changed and updated to show that every records have the same values
for
> > all fields...
> >
> > does anybody know why that is and possible how to fix that problem so
only
> > that record gets changed? my source is rather huge in size and since i
cant
> > find the place where the problem is coming from it would be hard to post
all
> > the source here..
> >
> > can anybody help?
> >
> > my update statement has all 16 fields in it because i dont know if you
can
> > do conditional updates with variables and if you can how to do that...
> >
> > ---
> > Outgoing mail is certified Virus Free.
> > Checked by AVG anti-virus system (http://www.grisoft.com).
> > Version: 6.0.443 / Virus Database: 248 - Release Date: 1/10/2003
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.443 / Virus Database: 248 - Release Date: 1/10/2003


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

Reply via email to