Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-28-2005, 06:26 PM   PM User | #1
robojob
Regular Coder

 
Join Date: Jul 2005
Location: Oxfordshire, UK
Posts: 144
Thanks: 0
Thanked 0 Times in 0 Posts
robojob is an unknown quantity at this point
list box initial select

i have this code which produces a list box dependent on items in a table in my database. i am creating an update page and need this list box to show the inital selected item dependent on the record in the database.

the code for the list box is

PHP Code:
 <? $query="SELECT catagory FROM catagory order by catagory asc";

$result mysql_query ($query);
echo 
"<select name=catagory>Catagory</option>";
// printing the list box select command

while($nt=mysql_fetch_array($result)){//Array or records stored in $nt
echo "<option value=$nt[catagory]>$nt[catagory]</option>";
/* Option values are added by looping through the array */
}
echo 
"</select>";// Closing of list box 
?>
The record that are able to be updated are stored in a table called directory. this table has a catagory column. but when a new record is added the catagory is selected from a list box populated by the catagory table from the database. any suggestions on how i would add an initial selected item into the above code.

I have other list boxes with inital selections like:

Code:
<select name="start">
                  <option value="Jan">Jan</option>
                  <option value="Feb">Feb</option>
                  <option value="Mar">Mar</option>
                  <option value="Apr">Apr</option>
                  <option value="May">May</option>
                  <option value="June">June</option>
                  <option value="July">July</option>
                  <option value="Aug">Aug</option>
                  <option value="Sept">Sept</option>
                  <option value="Oct">Oct</option>
                  <option value="Nov">Nov</option>
                  <option value="Dec">Dec</option>
				    <option value="<?php echo($start) ?>" selected> 
                  <?php echo($start) ?>
                  </option>
                </select>
Thanks in advance.
robojob is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 02:33 PM.


Advertisement
Log in to turn off these ads.