View Single Post
  #8 (permalink)  
Old May 31st, 2006, 10:25 PM
harpua harpua is offline
Friend of Wrox
 
Join Date: Jun 2003
Location: Oklahoma City, Oklahoma, USA.
Posts: 249
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I hope I am understanding how you are wanting to add the Select section into the form.


<p>
Section:<br>

<select id="section_name" name="section_name" style="width:150px">
//It's a good idea to give this a blank select option or better yet test for results from DB first.
<option value="">Make A Selection</option>

<?php
//You are creating a variable, but never assigning it a value, there will never be a match.
//I am assuming this is your category so you need to have some way to send over the article ID and then retrieve it on the page using most likely using something like a $_POST or $_GET
$section_name = $_GET['article_id'];

$sql = "SELECT section_id, section_name FROM cms_section ORDER BY section_id";

$result = mysql_query($sql)
    or die("Query Error" . mysql_error());

// an cleaner way to write the loop option section would be
while ($row = mysql_fetch_array($result)) {

    echo '<option value="' . $row['section_id'] . '"';
    if ($row['section_id'] == $section_name) {
        echo ' selected';
    }
    echo '>' . $row['section_name'] . '</option>\r\n';
  }
?>
</select>
</p>
Reply With Quote