On Tue, 2002-02-05 at 16:23, Michael O'Neal wrote: > Hi. > > I'm working on an "edit" page where the pull down menu is populated from a > database. I can't figure out how to print "selected" when that particular > record is the one associated with the current ID. Can anyone help? > > Here's my current code: > > <!-- Dynamic Career Menu--> > > <?php > > include("common.inc"); > > > $connection = @mysql_connect("$db_host","$db_user","$db_pass") or
This isn't your problem, but you do not really need to quote the above variables. > die("Couldn't Connect."); > $db = @mysql_select_db($db_name, $connection) or die("Couldn't select > database."); > > > $sql ="SELECT job_id,category,description,job_id AS my_job_id FROM > $cat_table_name"; > $result = @mysql_query($sql, $connection) or die("Error #". mysql_errno() . > ": " . mysql_error()); > > while ($row = mysql_fetch_array($result)) { > > $job_id=$row['job_id']; > $category=$row['category']; > $description=$row['description']; > $my_job_id=$row['my_job_id']; > > > echo "<option value=\"$job_id\" "; > > if ($job_id == '$my_job_id') { ^^^^^^^^^^^^ This is your problem: remove the quotes. PHP does not interpolate single-quoted strings: http://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.single [snip] Hope this helps, Torben > -- > > Michael O'Neal > Web Producer -- Torben Wilson <[EMAIL PROTECTED]> http://www.thebuttlesschaps.com http://www.hybrid17.com http://www.inflatableeye.com +1.604.709.0506 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php