thank you very much for the help - after some modifications i got it to work i will post the complete script in case anyone strugling with similar thing but first couple of extra questions:
just for general knowledge - the numbers in the defined array 1,2,4,8 etc are they chosen for a reason? i.e. can i use 1,2,3,4,5,6 instead?
secondly if i want to store all possible Mood values in a separate table (for the sake of easily adding more values) how do i get the script to read of that table? do i need to store the above numbers too in that table ?
and thirdly - do i need to set the datatype of Mood to SET with a list of possible values or can i use VARCHAR? (will help by not needing to update it as well as the values table)
anyway this is my working script:
$result=mysql_query(" SELECT * FROM ppl_tracks WHERE Track='$record'");
$num=mysql_num_rows($result);
$i=0;
while ($i < $num) {
// collect all details for our one reference
$Description=mysql_result($result,$i,"Description");
$Artist=mysql_result($result,$i,"Artist");
$reference=mysql_result($result,$i,"Track");
$FileName=mysql_result($result,$i,"FileName");
$Keywords=mysql_result($result,$i,"Keywords");
$Mood=mysql_result($result,$i,"Mood");
$Composed=mysql_result($result,$i,"Composed");
$ID=mysql_result($result,$i,"RECNO");
# values from DB for this user
$Mood = explode(',', $Mood);
# all moods 'dreamy','calm','chilled','energetic','tense'
$Moods = array('dreamy' => 1, 'calm' => 2, 'chilled' => 4, 'energetic' => 8, 'tense' => 16);
?>
<TABLE WIDTH="100%" CELLPADDING="10" CELLSPACING="0" BORDER="2"> <TR ALIGN="center" VALIGN="top">
<TD ALIGN="center" COLSPAN="1" ROWSPAN="1" BGCOLOR="#F2F2F2">
<FORM ACTION="amend2.php" METHOD="post">
<P ALIGN="LEFT">
<INPUT TYPE="hidden" NAME="ud_id" VALUE="<? echo "$ID" ?>">
<BR>Description1:<BR>
<TEXTAREA NAME="ud_Description" COLS="50" ROWS="4">
<? echo "$Description"?>
</TEXTAREA></P>
<P ALIGN="LEFT">Artist:<BR>
<TEXTAREA NAME="ud_Artist" COLS="50" ROWS="4"><? echo "$Artist"?>
</TEXTAREA></P><HR>
<P ALIGN="LEFT">Thumbnail:<BR>
<INPUT TYPE="text" NAME="ud_FileName" VALUE="<? echo "$FileName"?>" SIZE="30" MAXLENGTH="50"></P>
<P ALIGN="LEFT">Image 1 :<BR>
<INPUT TYPE="text" NAME= VALUE="<? echo "$Keywords"?>" SIZE="30" MAXLENGTH="50"></P>
<P ALIGN="LEFT">Image 2 :<BR>
<?
echo '<select multiple="multiple" name="ud_Mood[]">';
foreach ($Moods as $k => $v) {
echo '<option value="'.$v.'"'. (in_array($k, $Mood) ? ' selected="selected">' : '>').$k.'</option>';
}
echo '</select>';?></P>
<P ALIGN="LEFT">Image 3 :<BR>
<INPUT TYPE="text" NAME="ud_Composed" VALUE="<? echo "$Composed"?>" SIZE="30" MAXLENGTH="50"><BR><BR></P>
<P>
<INPUT TYPE="Submit" VALUE="Update the Record"> </P></FORM></TD></TR></TABLE>
<?
++$i;
}
?>
and amend2.php
<?php
$ud_id=$_POST['ud_id'];
$ud_Description=$_POST['ud_Description'];
$ud_Artist=$_POST['ud_Artist'];
$ud_FileName=$_POST['ud_FileName'];
$ud_Keywords=$_POST['ud_Keywords'];
$ud_Mood = array_sum($_POST['ud_Mood']);
$ud_Composed=$_POST['ud_Composed'];
$con = mysql_connect("localhost","USER","PASS");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("memimom1_test", $con);
echo "<BR>Record $ud_Description <-- Updated<BR><BR>";
mysql_query(" UPDATE ppl_tracks
SET Description='$ud_Description', Mood='$ud_Mood' WHERE RECNO = '$ud_id'");
echo "<BR>Record $ud_id <-- Updated<BR><BR>";
mysql_close($con);
?>