I have a page to edit an article in a db.
When the article is initially added there is a multiple selection list box with records listed.
The user can select a number of records which is then submitted to the db with each record selected on a new line in a mediumtext field.
On the edit page I am trying to list all the records in the list box again but with the records that were added initially already selected.
I already have it sort of working using the following code:
However, using this code it lists each article twice
When the article is initially added there is a multiple selection list box with records listed.
The user can select a number of records which is then submitted to the db with each record selected on a new line in a mediumtext field.
On the edit page I am trying to list all the records in the list box again but with the records that were added initially already selected.
I already have it sort of working using the following code:
Code:
<select name="internal[]" size="15" multiple="multiple" id="internal[]">
<?
while ($internalRS = mysql_fetch_array($internalresults)) {
foreach(explode("\n", $editRS['internallinks']) as $intlinks)
{
$intlistSQL = "SELECT articleid, articletitle FROM mainarticle WHERE articleid = '" . $intlinks . "'";
$intlistresults = mysql_query($intlistSQL);
$intlistRS = mysql_fetch_array($intlistresults);
?>
<option value="<?= $internalRS['articleid'] ?>" <? if ($intlistRS['articleid'] == $internalRS['articleid']) { ?>selected="selected"<? } ?>>
<?= $internalRS['articletitle'] ?> - <?= $internalRS['maincatname'] ?> - <?= $internalRS['subcatname'] ?>
</option>
<? } } ?>
</select>
However, using this code it lists each article twice