Hi, looking at your sql statement, it seems like you are always setting 
my_job_id and job_id to the same value for each row in the table.  "select 
job_id AS my_job_id" is just putting the value of job_id in a variable 
called my_job_id.  Could you tell us the structure of your mysql table please?

Jeff

At 05:23 PM 2/5/2002 -0700, 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
>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') {
>
>                     echo " selected ";
>                 }
>
>echo " >$title</option>";
>
>
>}
>
>$num = @mysql_num_rows($result);
>
>
>?>
><!-- /Dynamic Career Menu-->
>
>
>This is about the 5th iteration of this menu I've been working on.  If
>anyone has any ideas, please email me at [EMAIL PROTECTED] as I am on the
>digest.
>
>Thanks,
>
>mto
>
>--
>
>Michael O'Neal
>Web Producer
>---------------------
>  M   A   N   G   O
>B  O  U  L  D  E  R
>---------------------
>http://www.thinkmango.com
>e- [EMAIL PROTECTED]
>p- 303.442.1821
>f- 303.938.8507
>
>
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php



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

Reply via email to