Jump to content

Code help please


TaosBill

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.