Hi,
I'm struggling to update my table with columns that are identified through variables. For example, I want to update Day3 using the hidden field "NewDay." Eventually, all of my days will be set using hidden field variable. Right now the trouble seems to be the statement %s=%s. Any suggests how to make the column defined by a variable. Thank you in advance. -Dave

$updateSQL = sprintf("UPDATE schedule SET Day1=%s, Day2=%s, %s=%s, Day4=%s, Day5=%s, Day6=%s, Day7=%s, Day8=%s, Day9=%s, Day10=%s, Day11=%s, Day12=%s, Day13=%s, Day14=%s, Day15=%s, Day16=%s, Day17=%s, Day18=%s, Day19=%s, Day20=%s, Day21=%s, Day22=%s, Day23=%s, Day24=%s, Day25=%s, Day26=%s, Day27=%s, Day28=%s, Day29=%s, Day30=%s, Day31=%s, Day32=%s, Day33=%s, Day34=%s, Day35=%s, Day36=%s, Day37=%s, Day38=%s, Day39=%s, Day40=%s, Day41=%s, Day42=%s WHERE UserID=%s",
                       GetSQLValueString($_POST['RadioGroup1'], "text"),
                       GetSQLValueString($_POST['RadioGroup2'], "text"),
                       GetSQLValueString($_POST['NewDay'], "text"),					   
                       GetSQLValueString($_POST['RadioGroup3'], "text"),
                       GetSQLValueString($_POST['RadioGroup4'], "text"),
                       GetSQLValueString($_POST['RadioGroup5'], "text"),
                       GetSQLValueString($_POST['RadioGroup6'], "text"),
                       GetSQLValueString($_POST['RadioGroup7'], "text"),
                       GetSQLValueString($_POST['RadioGroup8'], "text"),
                       GetSQLValueString($_POST['RadioGroup9'], "text"),
                       GetSQLValueString($_POST['RadioGroup10'], "text"),
                       GetSQLValueString($_POST['RadioGroup11'], "text"),
                       GetSQLValueString($_POST['RadioGroup12'], "text"),
                       GetSQLValueString($_POST['RadioGroup13'], "text"),
                       GetSQLValueString($_POST['RadioGroup14'], "text"),
                       GetSQLValueString($_POST['RadioGroup15'], "text"),
                       GetSQLValueString($_POST['RadioGroup16'], "text"),
                       GetSQLValueString($_POST['RadioGroup17'], "text"),
                       GetSQLValueString($_POST['RadioGroup18'], "text"),
                       GetSQLValueString($_POST['RadioGroup19'], "text"),
                       GetSQLValueString($_POST['RadioGroup20'], "text"),
                       GetSQLValueString($_POST['RadioGroup21'], "text"),
                       GetSQLValueString($_POST['RadioGroup22'], "text"),
                       GetSQLValueString($_POST['RadioGroup23'], "text"),
                       GetSQLValueString($_POST['RadioGroup24'], "text"),
                       GetSQLValueString($_POST['RadioGroup25'], "text"),
                       GetSQLValueString($_POST['RadioGroup26'], "text"),
                       GetSQLValueString($_POST['RadioGroup27'], "text"),
                       GetSQLValueString($_POST['RadioGroup28'], "text"),
                       GetSQLValueString($_POST['RadioGroup29'], "text"),
                       GetSQLValueString($_POST['RadioGroup30'], "text"),
                       GetSQLValueString($_POST['RadioGroup31'], "text"),
                       GetSQLValueString($_POST['RadioGroup32'], "text"),
                       GetSQLValueString($_POST['RadioGroup33'], "text"),
                       GetSQLValueString($_POST['RadioGroup34'], "text"),
                       GetSQLValueString($_POST['RadioGroup35'], "text"),
                       GetSQLValueString($_POST['RadioGroup36'], "text"),
                       GetSQLValueString($_POST['RadioGroup37'], "text"),
                       GetSQLValueString($_POST['RadioGroup38'], "text"),
                       GetSQLValueString($_POST['RadioGroup39'], "text"),
                       GetSQLValueString($_POST['RadioGroup40'], "text"),
                       GetSQLValueString($_POST['RadioGroup41'], "text"),
                       GetSQLValueString($_POST['RadioGroup42'], "text"),
                       GetSQLValueString($_POST['UserID'], "int"));

  mysql_select_db($database_connJobvid, $connJobvid);
  $Result1 = mysql_query($updateSQL, $connJobvid) or die(mysql_error());

Use a regular variable like you would anywhere else. you can't use an expression like that in a sql statement. If it needs to be set to some starting value, do that above the sql statement then just use the variable in the statement.

This article has been dead for over six months. Start a new discussion instead.