TaosBill Posted May 27, 2008 Share Posted May 27, 2008 Trying to make a dynamic sql update statement from the string $headers. $headers = 'company,approved'; /*The results would be: a string containing: company='$company',approved=$'approved' */ $upd_columns = explode(",", $headers); $count_total = count($upd_columns); for ($counter=0; $counter<$count_total; $counter++){ $line = each ($upd_columns); echo "key ->" .$line[key]." value ->".$line[value]." <br />"; $col_fld = $line[value]; $col_var = ${$col_fld}; $colname = ''; $colname .= $col_fld; $colname .= " = '"; $colname .= ${$col_var}; // this doesn't work! $colname .= "',"; echo $colname."<br>"; $sql_upd .= $colname; } Thanks in advance Link to comment https://forums.phpfreaks.com/topic/107380-code-help-please/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.