Hi, I have a multi-select listbox set up like this:

Author (you are able to select more than one.<a href="addauthor.php">Click 
here to add a new author</a>)<br>:
<select name="author" multiple size=5>
<?php
  $result = mysql_query("SELECT AUTHOR_ID, AUTHOR_FNAME, AUTHOR_LNAME FROM 
AUTHORS;") or die(mysql_error());
  while ($row = mysql_fetch_array($result,MYSQL_ASSOC)) {
          $option = "<option value=" . $row["AUTHOR_ID"] . ">" . 
$row["AUTHOR_FNAME"] . " " . $row["AUTHOR_LNAME"] . "</option>";
          echo $option;
}
?>
</select><br>

I then have a bit of code that parses through and checks which authors they 
selected, if any.

if isset($author) {
         if is_array($author) {
                 foreach($authors as $key=>$value) {
                         $query = "INSERT INTO BYLINE(TITLE_ID, AUTHOR_ID) 
VALUES(" . $titleid . "," . $value . ");";
                         mysql_auery($query) or die(echo mysql_error());
                  }
         } else {
                 $query = "INSERT INTO BYLINE(TITLE_ID, AUTHOR_ID) VALUES(" 
. $titleid . "," . $author . ");";
                 mysql_auery($query) or die(echo mysql_error());
         }
}

What I'd like to know is, is this correct, incorrect, redundant, etc?

John Meyer
[EMAIL PROTECTED]
Programmer


If we didn't have Microsoft, we'd have to blame ourselves for all of our 
programs crashing


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to